怎么在php5.5中使用PHPMailer-5.2发送邮件-创新互联
这篇文章给大家介绍怎么在php5.5中使用PHPMailer-5.2发送邮件,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.exmail.qq.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xxx@qq.com'; // SMTP username
$mail->Password = 'yourpassword'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('fromWho@qq.com', 'Mailer');
$mail->addAddress('toWhom@qq.com', 'Ryan Miao'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
// $mail->addReplyTo('info@example.com', 'Information');
$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 in bold!';
$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';
}开启SMTPDebug可以查看日志
`0` No output
`1` Commands
`2` Data and commands
`3` As 2 plus connection status
`4` Low-level data output
错误信息保存在$mail->ErrorInfo对象中。
保存为mail.php, 命令行执行
php mail.php
关于怎么在php5.5中使用PHPMailer-5.2发送邮件就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
当前题目:怎么在php5.5中使用PHPMailer-5.2发送邮件-创新互联
网页路径:http://www.jxjierui.cn/article/dsdodi.html


咨询
建站咨询
