0

I have been struggling with this error for two days. But I don't know what is going on.

Everything was working well using phpMailer and a gmail account. Since gmail has a daily send limit we wanted to using sparkPost instead. Then, when we changed the user to the sparkPost one, we noticed that some emails were failing.

We have this phpmailer code:

$mail = new PHPMailer();
$mail->SMTPDebug = 1;
$mail->isSMTP();
$mail->Host = 'smtp.sparkpostmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->IsHTML(true);
$mail->CharSet = "UTF-8";
$mail->SMTPAuth = true;
$mail->Username = ''; //Sparkpost user
$mail->Password = ''; //Sparkpost pass   
$mail->setFrom($from, 'From Alias');
$mail->addAddress($recipient);
$mail->Subject = html_entity_decode( $subject , ENT_QUOTES, 'UTF-8') ;
$mail->Body    = $body;
$send = $mail->Send();
if (!$send) {
  $loginfo .= "Mailer Error: " . $mail->ErrorInfo . "\n";
 //Sends an email when the error ocurrs
} else {
  $loginfo .= "Mail has been sent";
     //OK
}

I have tried with 3 different email addresses insithe the setFrom() but all of them have failed at least once. I say this because is not always failing. For example, With the last address I have tried, we have 21 emails sent, only 2 of them have failed with this error.

EDIT This is the information I get with SMTPDebug = 2:

SMTP Error: Data not accepted.

SMTP server error: 2.0.0 RCPT TO accepted

DebugInfo: SMTP -> FROM SERVER:220 2.0.0 smtp.sparkpostmail.com ESMTP ecelerity 4.2.27.58261 r(Core:4.2.27.6) Wed, 11 Jan 2017 12:07:04 +0000


SMTP -> FROM SERVER: 250-momentum5.platform1.us-west-2.aws.cl.messagesystems.com says EHLO to 54.154.106.22:35238 250-8BITMIME 250-STARTTLS 250-AUTH=LOGIN PLAIN 250-AUTH LOGIN PLAIN 250-PIPELINING 250 ENHANCEDSTATUSCODES


SMTP -> FROM SERVER:220 2.0.0 continue


SMTP -> FROM SERVER: 250-momentum5.platform1.us-west-2.aws.cl.messagesystems.com says EHLO to 54.154.106.22:35238 250-8BITMIME 250-AUTH=LOGIN PLAIN 250-AUTH LOGIN PLAIN 250-PIPELINING 250 ENHANCEDSTATUSCODES


SMTP -> ERROR: Password not accepted from server:
SMTP -> FROM SERVER:235 2.0.0 Authed. Go on.


SMTP -> ERROR: RSET failed: 235 2.0.0 Authed. Go on.


SMTP -> FROM SERVER:250 2.0.0 RSET OK


SMTP -> FROM SERVER:250 2.0.0 MAIL FROM accepted


SMTP -> FROM SERVER:250 2.0.0 RCPT TO accepted


SMTP -> ERROR: DATA command not accepted from server: 250 2.0.0 RCPT TO accepted


SMTP Error: Data not accepted.

Any idea? Thanks in advance

Adrián Rodriguez
  • 430
  • 11
  • 26
  • It doesn't help you debug when you're disabling debug output and not displaying the error. Have you tried doing what the troubleshooting guide says? – Synchro Jan 10 '17 at 12:29
  • I'm not disabling it. It is enable by default, the result is the same with $mail->SMTPDebug = 1; And the error I get is the one I put on the title Mailer Error: The following From address failed: $recipient : MAIL not accepted from server,,

    SMTP server error:

    SMTP server error:

    – Adrián Rodriguez Jan 10 '17 at 15:29
  • Looks like that `$recipient` variable is blank. – Dave Gray Jan 10 '17 at 16:48
  • You changed your code after my comment. SMTPDebug = 1 is useless for this, you need 2 to see what the server says, which you would know if you read the docs the error message points to. If you're not seeing a link, you need to update as it means you're running an old, buggy, vulnerable version. – Synchro Jan 10 '17 at 23:43
  • @Synchro Ok thanks, I'll review that – Adrián Rodriguez Jan 11 '17 at 08:16
  • @DaveGray why you think so? $recipient is not blank. I'm logging the content of the mail and the ErrorInfo and everithing is ok but, sometimes, the send fails – Adrián Rodriguez Jan 11 '17 at 08:16
  • I noticed the two quotes right next to each other in the post title - maybe it's not from `$recipient` but would be good to understand why you're getting "" in the error message. – Dave Gray Jan 12 '17 at 05:35
  • Also, that SMTP log looks really odd. There are errors on the same line as successes? `SMTP -> ERROR: DATA command not accepted from server: 250 2.0.0 RCPT TO accepted` – Dave Gray Jan 12 '17 at 05:36
  • @DaveGray I'm not getting "". I meant with that that is happening to me with every email address I have tried so it was like a placeholder for the address I was using in the setFrom() function. I don't know everything is too strange. Why having the same mail in the from it fails sometimes and not always? – Adrián Rodriguez Jan 12 '17 at 07:55
  • How much do your message bodies vary in size? https://stackoverflow.com/a/15975485/857156 – Dave Gray Jan 12 '17 at 18:47
  • @DaveGray they are orders mails. Their body size depends on the amount of products our customers buy. But I don't think the failure depends on the body size, I have fails in orders with only one product and fails in orders with more than five items. – Adrián Rodriguez Jan 13 '17 at 09:14

0 Answers0