Skip to content

Add config option to disable PHPmailer's SMTPAutoTLS

pitchum requested to merge pitchum/framadate:fix-phpmailer-issues into master

The problem: even if we set the option "secure => ''" it is possible that STARTTLS is still enabled when sending an email. This is caused by the SMTPAutoTLS parameter from PHPMailer which is set to true by default. This option allows enabling STARTTLS when some conditions are effective:

  1. openssl extension is available
  2. the STMP server offers STARTTLS

This is probably a good approach to enforce encryption when possible but when the TLS negociation fails PHPMailer's log message is not very explicit:

PHP Fatal error:  Uncaught PHPMailer\\PHPMailer\\Exception: SMTP Error: Could not connect to SMTP host.

There is already a report for this: PHPMailer #1405 Improve feedback on TLS errors.

Until it is fixed I suggest adding a new configuration parameter in framadate: autotls with a comment giving a hint about when it may be useful set it to false. And for this to work I had to modify the function "configureMailer" to allow boolean 'false' values to be passed to PHPMailer.

Merge request reports