Respect override in settings.php

Created on 15 April 2021, over 3 years ago
Updated 17 January 2024, 10 months ago

Problem/Motivation

When I debug an existing site, I download a dump to my local setup and check the site locally. On the production site, smtp module is enabled - but I do not want to send emails from my local setup. I use mailhog to check all mails my local drupal sites are sending - but with emails sent by smtp module, this setup does not work anymore.

So I've put $config['smtp.settings']['smtp_on'] = FALSE; in my settings.local.php - but these settings are ignored until I submit the configuration form of the smtp module.

Proposed resolution

I've entered some lines of code to SMTPMailSystem Class, to respect the overriden value and use the drupal core mail Class instead. As this class is using php mail() function, the settings in php.ini is used again.

Remaining tasks

Please test the patch I'm adding to this issue and if it's ok for the mantainer, add this lines to prevent unwanted mail submits. (I've never tried this before ... so I hope, the patch can be used as is but please be patient if it isn't).

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇦🇹Austria anschinsan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom mbatterton

    The patch 3208955-8.patch does respect the override in the settings.php but fails to allow emails to be sent when not overridden. We tried this with Brevo (SendInBlue). Please use it with caution.

  • @sgoodwin's solution in #4 didn't work for me, however this does the trick:

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

    When you switch the smtp module OFF, it also modifies the system.mail config.

    I hope my comment doesn't result in this issue going stale ':[]

Production build 0.71.5 2024