PHPMailer’s SMTPKeepAlive option

Hi there,

have you ever used the SMTPKeepAlive option?

It’s a PHPMailer setting. SuiteCRM does not use it by default, but the option is available in the PHPMailer class.

It could improve mass email campaign performance, but there is one important aspect to consider.

During the campaign delivery loop, SuiteCRM may change the outbound SMTP account.

In that case, SuiteCRM should update the mailer object with the correct SMTP host, port, SSL/TLS settings, authentication flag, username, and password.

If SMTPKeepAlive is enabled without properly handling this scenario, SuiteCRM might keep an SMTP connection open while switching the configuration to another SMTP account. This could cause unexpected behavior or delivery failures.

So, in my opinion, a safe implementation should either:

  1. enable keep-alive only when all emails in the batch use the same SMTP account;
  2. close and reopen the SMTP connection whenever the outbound SMTP account changes;
  3. or group campaign delivery by outbound SMTP account.

What are your thoughts on this?