<?php
require_once "vendor/autoload.php";
$mail = new PHPMailer;
$mail->SMTPDebug = 0;
$mail->isSMTP();
$mail->Host = "localhost";
$mail->SMTPAuth = false;
$mail->Username = "xxx@xxxx.com";
$mail->Password = "xxxxxxx";
$mail->SMTPSecure = "tls";
$mail->Port = 25;
$mail->From = "xxx@xxxxx.com"
$mail->FromName = "xxx";
$mail->addAddress("example@gmail.com", "example");
$mail->isHTML(true);
$mail->Subject = "Test";
$mail->Body = "<i>Helo</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
梅勒错误:
SMTP错误:未接受数据.STP服务器错误:DATA END命令 失败详细信息:标题中缺少内部数据。消息丢弃了。 SMTP代码:550
答案 0 :(得分:0)
在回答相关问题PHP mail function doesn't complete sending of e-mail时,对于PHP邮件问题有一个很好的疑难解答。
其中的细节是标题的一些细节,这可能会有所帮助。这是一对夫妇:
确保提供所有邮件标题
如果邮件缺少常用标题,某些垃圾邮件软件会拒绝邮件 例如“From”和“Reply-to”:
$headers = array("From: from@example.com",
"Reply-To: replyto@example.com",
"X-Mailer: PHP/" . PHP_VERSION
);
$headers = implode("\r\n", $headers);
mail($to, $subject, $message, $headers);
确保邮件标头没有语法错误
无效的标头与没有标头一样糟糕。一个不正确 角色可能只是破坏你的电子邮件。仔细检查 确保您的语法正确,因为PHP不会捕获这些错误 对你而言。
$headers = array("From from@example.com", // missing colon
"Reply To: replyto@example.com", // missing hyphen
"X-Mailer: "PHP"/" . PHP_VERSION // bad quotes
);