From e865420774c0e4d267cc2a3429e5dc4a95c62c6b Mon Sep 17 00:00:00 2001 From: mark burdett Date: Tue, 20 Mar 2018 04:01:20 -0700 Subject: [PATCH] CRM-20320: if SMTP connection error is detected, disconnect so we can reconnect, and retry the group later to complete delivery --- CRM/Mailing/BAO/MailingJob.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CRM/Mailing/BAO/MailingJob.php b/CRM/Mailing/BAO/MailingJob.php index 0d49819d64..ced5924cea 100644 --- a/CRM/Mailing/BAO/MailingJob.php +++ b/CRM/Mailing/BAO/MailingJob.php @@ -608,6 +608,7 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) $returnProperties = $mailing->getReturnProperties(); $params = $targetParams = $deliveredParams = array(); $count = 0; + $retryGroup = FALSE; // CRM-15702: Sending bulk sms to contacts without e-mail address fails. // Solution is to skip checking for on hold @@ -694,9 +695,11 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) CRM_Core_Error::debug_log_message("SMTP Socket Error or failed to set sender error. Message: $message, Code: $code"); // these are socket write errors which most likely means smtp connection errors - // lets skip them + // lets skip them and reconnect. $smtpConnectionErrors++; if ($smtpConnectionErrors <= 5) { + $mailer->disconnect(); + $retryGroup = TRUE; continue; } @@ -786,6 +789,10 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) $job_date ); + if ($retryGroup) { + return FALSE; + } + return $result; } -- 2.25.1