我在我的网站上使用phpmailer大约2个月,向我的用户发送电子邮件,并提供有关技术等信息的一些信息。当用户访问网站并单击"获取我的月报纸"按钮时,该电子邮件将发送。电子邮件的内容只是身体上的一些文本,还有一个带有信息的PDF文件。一切都很好,电子邮件是没有麻烦的,但是今天,一个用户向我发送了一封电子邮件,告诉我他在单击按钮时没有收到他的电子邮件。当我检查PHP Mailsender文件时,我收到了此错误消息:
SMTP Error: data not accepted.
我使用$邮递 -> smtpdebug = true来获取更多错误的详细信息,这是我收到的消息的一部分:
//this is the first part of the message:
2019-06-30 02:29:11 SMTP INBOUND: "235 2.7.0 Authentication successful"
2019-06-30 02:29:11 SERVER -> CLIENT: 235 2.7.0 Authentication successful
2019-06-30 02:29:11 CLIENT -> SERVER: MAIL FROM:<here is the same email of SMTP username>
2019-06-30 02:29:11 SMTP INBOUND: "250 2.1.0 Sender OK"
2019-06-30 02:29:11 SERVER -> CLIENT: 250 2.1.0 Sender OK
2019-06-30 02:29:11 CLIENT -> SERVER: RCPT TO:<here the email of the user>
2019-06-30 02:29:11 SMTP INBOUND: "250 2.1.5 Recipient OK"
2019-06-30 02:29:11 SERVER -> CLIENT: 250 2.1.5 Recipient OK
2019-06-30 02:29:11 CLIENT -> SERVER: DATA
2019-06-30 02:29:10 Connection: opening to smtp.office365.com:587, timeout=20, options=array()
2019-06-30 02:29:10 Connection: opened
//this is the part where show the error:
2019-06-30 02:29:12 SMTP INBOUND: "554 5.2.0 STOREDRV.Submission.Exception:InvalidLicenseException; Failed to process message due to a permanent exception with message Mailbox 'here the mailbox code' doesn't have a valid license. InvalidLicenseException: Mailbox 'here the mailbox code' doesn't have a valid license. [Hostname=here the host code]"
SMTP Error: data not accepted.
SMTP Error: data not accepted.
2019-06-30 02:29:12 CLIENT -> SERVER: QUIT
2019-06-30 02:29:12 SMTP INBOUND: "221 2.0.0 Service closing transmission channel"
2019-06-30 02:29:12 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
2019-06-30 02:29:12 Connection: closed
这是我的emailsender.php文件,要发送电子邮件的代码为:
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerException;
/* Exception class. */
require 'PHPMailer/src/Exception.php'; //PHPMailer
/* The main PHPMailer class. */
require 'PHPMailer/src/PHPMailer.php';
/* SMTP class, needed if you want to use SMTP. */
require 'PHPMailer/src/SMTP.php';
$mail = new PHPMailer(TRUE);
$mail->isSMTP();
$mail->Host= 'smtp.office365.com'; // (SMTP)
$mail->SMTPAuth= 'true';
$mail->Username= 'username email for SMTP';
$mail->Password= 'here the password of SMTP';
$mail->SMTPSecure= 'tls';
$mail->Port= '587';
$mail->SMTPDebug = true;
$mail->Timeout = 20;
$emailUsers = trim("usermail@mailserver.com", " ");
$message = "";
try {
/* Set the mail sender. */
$mail->setFrom("here the same email of USERNAME SMTP", "Admin");
$mail->addAddress($emailUsers);
/* Set the subject. */
$mail->Subject = 'Month Newspaper';
$mail->isHTML(TRUE);
/* Set the mail message body. */
$message = '<html>'.
'<head><title>Nivagastro Order Details</title></head>'.
'<body><h4 style="color: blue;"> Welcome to your Month Newspaper. UserAddress: '.utf8_decode('here the address of the user').' UserAuthWord: '.utf8_decode('This is the auth word of user').'!</h4>'.
'<hr style="margin-right: 100px;">'.
'<span>We will have new surprises for you the next month. More topics and news. Back soon!</span>'.
'</body>'.
'</html>';
$mail->Body = $message;
$mail->MsgHTML = $message;
$mail->AltBody = $message;
$mail->AddAttachment("files/NewspaperJun19.pdf"); // attachment
if(!$mail->send())
{
//echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "YOUR EMAIL HAS BEEN SEND SUCCESSFULY";
}
}
catch (Exception $e)
{
/* PHPMailer exception. */
echo $e->errorMessage();
}
catch (Exception $e)
{
/* PHP exception (note the backslash to select the global namespace Exception class). */
echo $e->getMessage();
}
您是否知道为什么直到昨天运行良好时才会显示此错误?以及我如何解决这个问题?
请查看SMTP调试日志:
2019-06-30 02:29:12 SMTP INBOUND: "554 5.2.0 STOREDRV.Submission.Exception:InvalidLicenseException; Failed to process message due to a permanent exception with message Mailbox 'here the mailbox code' doesn't have a valid license. InvalidLicenseException: Mailbox 'here the mailbox code' doesn't have a valid license. [Hostname=here the host code]"
inbound 消息" invalidlicenseException:邮箱'在这里邮箱代码'没有有效的许可证。[hostName = there there the主机代码] 指向主要问题是用户的邮箱,似乎没有所需的许可证。
有关用户是否使用与您在网站上注册相同的发件人地址向您发送了电子邮件?在那种情况下,回答该电子邮件可能是一个有趣的测试 - 它是否可以通过用户进行...