标签:orm dad connect html body option pos erro from
把"phpmailer/phpmailer": "~5.2"放到conposer.json下面
命令行执行conposer 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‘;
}
标签:orm dad connect html body option pos erro from
原文地址:http://www.cnblogs.com/peng0728/p/7157100.html