【问题标题】:Error SMTP Error: data not accepted in PHPMailer错误 SMTP 错误:PHPMailer 中不接受数据
【发布时间】:2019-06-30 03:20:04
【问题描述】:

我已经在我的网站上使用 PHPMailer 大约 2 个月来向我的用户发送一封电子邮件,其中包含一些关于技术的信息和类似的东西。当用户访问网站并单击“获取我的月报”按钮时,会发送此电子邮件。电子邮件的内容只是正文上的一些文本和包含信息的 pdf 文件。一切工作正常,电子邮件发送没有问题,但今天有用户给我发了一封电子邮件,告诉我当他点击按钮时他没有收到他的电子邮件。当我检查 php mailsender 文件时,我收到此错误消息:

 SMTP Error: data not accepted.

我使用 $mail->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 PHPMailer\PHPMailer\PHPMailer;
                use PHPMailer\PHPMailer\Exception;

                /* 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();
                }

您是否知道为什么在昨天运行良好的情况下现在显示此错误?以及如何解决这个问题?

【问题讨论】:

  • 这听起来像是那个用户的邮箱有问题,而不是你的代码。

标签: php pdf phpmailer html-email email-attachments


【解决方案1】:

查看 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: Mailbox 'here the mailbox code' does not have a valid license. [Hostname=here the host code]” 指向主要问题是用户的邮箱,它似乎没有所需的许可证。

相关用户是否使用与在您的网站上注册时相同的发件人地址向您发送电子邮件?在那种情况下,回复那封电子邮件可能是一个有趣的测试——它是否会传达给用户...

【讨论】:

  • 用户用他自己的电子邮件帐户给我写信,但他不是通过我网站上的表格写信的,他是用传统方式写的。他不是唯一有这个问题的用户。
  • 我有几个网页,我也使用 phpmailer 和这些 smtp 凭据来发送联系表格和类似的东西。但我没有检查这些页面是否存在相同的错误。
  • 澄清一下,我假设“这里是邮箱代码”和“这里是主机代码”是指来自用户地址的数据。这是正确的还是真的有你自己的发件人地址?
猜你喜欢
  • 2016-10-22
  • 2013-03-30
  • 1970-01-01
  • 2017-10-15
  • 2017-07-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-19
相关资源
最近更新 更多