使用PHPMailer发送SMTP消息,“MAIL未被服务器接受”的响应,为什么?

时间:2021-01-09 18:11:40

I've been banging my head trying to sort this one out... any clues would be greatly appreciated.

我一直在试图将这个排除在外...任何线索都会非常感激。

I am sending mail via PHPMailers SMTP class locally on a Ubuntu 12.04 server running exim. If I send only 10 messages everything works fine. However if I queue up say 260+ messages and try to send them one after another I can guarantee that ~30 of them will be returned with the line:

我在运行exim的Ubuntu 12.04服务器上本地通过PHPMailers SMTP类发送邮件。如果我只发送10条消息,一切正常。但是,如果我排队说出260多条消息并尝试一个接一个地发送它们,我可以保证它们中的~30个将随行返回:

MAIL not accepted from server

MAIL不接受服务器

They're all going to the same address (and the other 230 make it there successfully) and I can see at times the queue in exim is functioning, so what could be causing this and why wouldnt this sort of error occur if I were just using the 'Mail' command?

他们都去了同一个地址(另外230个成功地在那里)我可以看到exim中的队列有时正在运行,所以可能导致这个以及为什么如果我只是这样就会发生这种错误使用'邮件'命令?

Thanks in advance.

提前致谢。

Ben

P.S: I'm not using the mail command because I'm actually extract the message ID from the SMTP output

P.S:我没有使用mail命令,因为我实际上是从SMTP输出中提取消息ID

UPDATE

I've done some more digging in PHPMailers class.smtp.php file and within the Mail function added a var_dump or two and Ive also pushed the debugging level upto 4 (so that I see every SMTP response). It seems that the $this->getLines() function is reading a blank line from the socket... which class.smtp.php is interpreting (presumably incorrectly) and then bailing out. Is this a valid response? Why would the telnet return nothing..?

我已经在PHPMailers class.smtp.php文件中进行了一些挖掘,并在Mail函数中添加了一个或两个var_dump,我也将调试级别提高到4(这样我就可以看到每个SMTP响应)。似乎$ this-> getLines()函数正在从套接字中读取一个空行... class.smtp.php正在解释(可能是错误的)然后挽救。这是一个有效的回应吗?为什么telnet什么都不返回..?

3 个解决方案

#1


0  

  1. Did you try putting sleep(1); delay between the mails? There might be a limit on how many mails you can send in a certain amount of time.

    你试过睡觉吗(1);邮件之间的延迟?您可以在一定时间内发送的邮件数量有限。

  2. Check the time when that error happens, how long has the script been working? It seems that the mail server login time expires. Divide the emails by smaller amounts and do a new login after 20 or so sent emails.

    检查错误发生的时间,脚本运行了多长时间?似乎邮件服务器登录时间到期。将电子邮件分成较小的金额,并在20个左右发送电子邮件后进行新的登录。

#2


0  

The error you receive should be more informative than that, e.g.

您收到的错误应该提供更多信息,例如

ERROR: MAIL not accepted from server: 550 Tarpit active for...

or something like that. The second part of the message should tell you what the error is. Otherwise, you should be able to see the reason in the mail log messages - /var/log/messages, /var/log/mail*, etc.

或类似的东西。消息的第二部分应该告诉您错误是什么。否则,您应该能够在邮件日志消息中看到原因 - / var / log / messages,/ var / log / mail *等。

UPDATE: here's why I said that:

更新:这就是我说的原因:

if($code != 250) {
  $this->error =
    array("error" => "MAIL not accepted from server",
          "smtp_code" => $code,
          "smtp_msg" => substr($rply,4));
  if($this->do_debug >= 1) {
    echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
  }
  return false;
}

...so the error should have included also the SMTP code and/or the message, not just "MAIL not accepted from server".

...所以错误应该包括SMTP代码和/或消息,而不仅仅是“MAIL不能从服务器接受”。

Anyway, the reason for the error should have been logged by the server, and be available in /var/log/exim4/rejectlog or /var/log/exim4/mainlog or the like.

无论如何,错误的原因应该由服务器记录,并且可以在/ var / log / exim4 / rejectlog或/ var / log / exim4 / mainlog等中使用。

#3


0  

I have same problem 1 day ago with PHPMailer class, i got error message: MAIL not accepted from server: with no further error detail. I have got a simple solution, i do SetFrom("my@email.com", "My Name") before do Send() and it is works. I guess it is about SMTP server which requiring a 'FROM' header for sending trough the SMTP server. I hope it will be useful for someone who may come to this thread and have same problem with me.

我有1天前与PHPMailer类有同样的问题,我收到错误消息:MAIL不接受服务器:没有进一步的错误细节。我有一个简单的解决方案,我做SetFrom(“my@email.com”,“我的名字”)之前做Send()它是有效的。我想这是关于SMTP服务器,需要一个'FROM'标题通过SMTP服务器发送。我希望对于那些可能会遇到这个问题且对我有同样问题的人来说,这会很有用。

#1


0  

  1. Did you try putting sleep(1); delay between the mails? There might be a limit on how many mails you can send in a certain amount of time.

    你试过睡觉吗(1);邮件之间的延迟?您可以在一定时间内发送的邮件数量有限。

  2. Check the time when that error happens, how long has the script been working? It seems that the mail server login time expires. Divide the emails by smaller amounts and do a new login after 20 or so sent emails.

    检查错误发生的时间,脚本运行了多长时间?似乎邮件服务器登录时间到期。将电子邮件分成较小的金额,并在20个左右发送电子邮件后进行新的登录。

#2


0  

The error you receive should be more informative than that, e.g.

您收到的错误应该提供更多信息,例如

ERROR: MAIL not accepted from server: 550 Tarpit active for...

or something like that. The second part of the message should tell you what the error is. Otherwise, you should be able to see the reason in the mail log messages - /var/log/messages, /var/log/mail*, etc.

或类似的东西。消息的第二部分应该告诉您错误是什么。否则,您应该能够在邮件日志消息中看到原因 - / var / log / messages,/ var / log / mail *等。

UPDATE: here's why I said that:

更新:这就是我说的原因:

if($code != 250) {
  $this->error =
    array("error" => "MAIL not accepted from server",
          "smtp_code" => $code,
          "smtp_msg" => substr($rply,4));
  if($this->do_debug >= 1) {
    echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
  }
  return false;
}

...so the error should have included also the SMTP code and/or the message, not just "MAIL not accepted from server".

...所以错误应该包括SMTP代码和/或消息,而不仅仅是“MAIL不能从服务器接受”。

Anyway, the reason for the error should have been logged by the server, and be available in /var/log/exim4/rejectlog or /var/log/exim4/mainlog or the like.

无论如何,错误的原因应该由服务器记录,并且可以在/ var / log / exim4 / rejectlog或/ var / log / exim4 / mainlog等中使用。

#3


0  

I have same problem 1 day ago with PHPMailer class, i got error message: MAIL not accepted from server: with no further error detail. I have got a simple solution, i do SetFrom("my@email.com", "My Name") before do Send() and it is works. I guess it is about SMTP server which requiring a 'FROM' header for sending trough the SMTP server. I hope it will be useful for someone who may come to this thread and have same problem with me.

我有1天前与PHPMailer类有同样的问题,我收到错误消息:MAIL不接受服务器:没有进一步的错误细节。我有一个简单的解决方案,我做SetFrom(“my@email.com”,“我的名字”)之前做Send()它是有效的。我想这是关于SMTP服务器,需要一个'FROM'标题通过SMTP服务器发送。我希望对于那些可能会遇到这个问题且对我有同样问题的人来说,这会很有用。