CiviMail: If SMTP connection error is detected, disconnect so we can reconnect and retry #11840
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
If an SMTP connection error is detected, then we should disconnect so that a reconnect is possible. In addition, we'll need to retry any deliveries that had an SMTP error later on. Fixes https://issues.civicrm.org/jira/browse/CRM-20320
Before
Currently, if there is an SMTP timeout, multiple errors are logged (initially code: 421, response: Timeout waiting for data from client; followed by SMTP: Failed to write to socket: unknown error). After 6 such errors, CiviMail gives up sending mail.
After
When an SMTP connection error is detected, CiviMail should disconnect the SMTP connection so that a reconnect is possible on the next attempt. We also need to record the delivery group as not completed so it can be retried later.
Technical Details
With this change, Mailer Batch Limit can be set to 0, allowing mailings to be delivered continously as fast as possible, rather than stopping with an error condition and waiting for a new cron job to start.