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:
MAIL not accepted from server
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?
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
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..?
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.
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.
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.
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".
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.
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.