conposer phpmailer 发邮件
Posted 鹏哥哥blog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了conposer phpmailer 发邮件相关的知识,希望对你有一定的参考价值。
把"phpmailer/phpmailer": "~5.2"放到composer.json下面
命令行执行composer update 在vendor下面会出现PHPMailer文件夹
进入vendor/composer/autoload_classmap.php
复制一行
写成最后一行,然后控制器use PHPMailer;
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = \'smtp.163.com\'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = \'18830428521@163.com\'; // SMTP username
$mail->Password = \'gzp910728\'; // SMTP password
$mail->SMTPSecure = \'tsl\'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; // TCP port to connect to
$mail->setFrom(\'18830428521@163.com\', \'鹏大哥\');
// $mail->addAddress(\'1406002855@qq.com\', \'鹏哥哥\'); // Add a recipient
$mail->addAddress(\'1406002855@qq.com\'); // Name is optional
$mail->addReplyTo(\'1406002855@qq.com\', \'鹏哥哥\');
// $mail->addCC(\'cc@example.com\');
// $mail->addBCC(\'bcc@example.com\');
// $mail->addAttachment(\'/var/tmp/file.tar.gz\'); // Add attachments
// $mail->addAttachment(\'/tmp/image.jpg\', \'new.jpg\'); // Optional name
$mail->ishtml(true); // Set email format to HTML
$mail->Subject = \'Here is the subject\';
$mail->Body = \'This is the HTML message body <b>in bold!</b>\';
$mail->AltBody = \'This is the body in plain text for non-HTML mail clients\';
if(!$mail->send()) {
echo \'Message could not be sent.\';
echo \'Mailer Error: \' . $mail->ErrorInfo;
} else {
echo \'Message has been sent\';
}
以上是关于conposer phpmailer 发邮件的主要内容,如果未能解决你的问题,请参考以下文章