From: mark burdett Date: Sat, 24 Mar 2018 22:28:41 +0000 (-0700) Subject: Detect additional SMTP temporary failure modes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4579b27df4e48e87c7cce3068ecde89d03e117ae;p=civicrm-core.git Detect additional SMTP temporary failure modes e.g. code: 454, response: Throttling failure: Maximum sending rate exceeded. --- diff --git a/CRM/Mailing/BAO/MailingJob.php b/CRM/Mailing/BAO/MailingJob.php index 0d49819d64..b0a510655c 100644 --- a/CRM/Mailing/BAO/MailingJob.php +++ b/CRM/Mailing/BAO/MailingJob.php @@ -685,9 +685,16 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) if (is_a($result, 'PEAR_Error') && !$mailing->sms_provider_id) { // CRM-9191 $message = $result->getMessage(); + // SMTP response code is buried in the message. + $code = preg_match('/ \(code: (.+), response: /', $message, $matches) ? $matches[1] : ''; if ( strpos($message, 'Failed to write to socket') !== FALSE || - strpos($message, 'Failed to set sender') !== FALSE + (( + strpos($message, 'Failed to set sender') !== FALSE || + strpos($message, 'Failed to add recipient') !== FALSE || + strpos($message, 'Failed to send data') !== FALSE + // Register 5xx SMTP response code (permanent failure) as bounce. + ) && substr($code, 0, 1) !== '5') ) { // lets log this message and code $code = $result->getCode();