We normally use Mailhog to capture outgoing mail during local development. But that doesn't work when using this module as Drupal/PHP is reaching out directly to the SMTP server.

I have this line in a settings.php file used specifically for local development.

// Disable SMTP module if it's enabled, and use the Drupal/System email handler. This will prevent accidental sending of emails, bypassing Mailhog.
$config['smtp.settings']['smtp_on'] = FALSE;

This doesn't actually seem to do anything other than display a status message "SMTP module is INACTIVE." on the settings form and hide some fields on that form. But functionally, the module still sends out email.

It would be helpful to disable this for our dev environments. It seems there was a similar issue for the D7 version of this module. #2193183: SMTP On/Off flag does not work. Looking at the patch for that issue though, it seems that the setting only really is used in the form submit handler, which switches the mail system that gets used on save.

So I figured out that the option I actually want is

$config['system.mail']['interface']['default'] = 'php_mail';

So I guess this is already a non-issue, but I've already written it up, and will leave it here for others to find.

Comments

bburg created an issue.

maskedjellybean’s picture

Thank you! I can confirm that your suggestion works.

I guess the smtp module does not respect the config override system. Hard to see how that is "works as designed", but as long as there is a work around I'm happy.