Add a killswitch for sending mails with drupal symfony mailer

Created on 16 August 2023, 11 months ago
Updated 3 November 2023, 8 months ago

Problem/Motivation

As professional site owner, i want to be sure that no email goes out of dev sites.

Given that virtually every site owner needs this, i feel this is much more Batteries-Included than Feature-Bloat.

Also, the documented custom alters β†’ give no perfect safety, there can always be a re-alter.

Proposed resolution

Add a overridable config that can be set on dev like

// All processing (e.g. logging) will happen, but the final mail will not go to any transport.
$config['mailer_killswitch'] =TRUE;

We can bikeshed about naming, i have no feelings about that.

Will you accept a patch?

Remaining tasks

✨ Feature request
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

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

Comments & Activities

  • Issue created by @geek-merlin
  • πŸ‡¬πŸ‡§United Kingdom AdamPS

    Will you accept a patch?

    Could do, but let's check out the other options first.

    Also, the documented custom alters give no perfect safety, there can always be a re-alter.

    When a hook throws SkipSending no one else can alter.

    Another option: make only one transport on the test site = null transport

    Also see ✨ Support for Reroute Email Closed: won't fix

  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    Yes, let's see see problem space and options.

    RerouteEmail: I know this and it's the other approach.
    Also there is MailSafety, and πŸ› No mail with symfony_mailer Needs work

    > When a hook throws SkipSending no one else can alter.
    Thx, i did not see that.

    > Another option: make only one transport on the test site = null transport
    Can this give us a single config override that gives us safety that no mail is sent?
    A config override that is the same for all dev environments, and simply auditable (i look into the settings and know that no customer ouch will happen)?
    (That's the driver here!)

  • πŸ‡¬πŸ‡§United Kingdom AdamPS

    Given that virtually every site owner needs this,

    Only you and I are following the issueπŸ˜ƒ.

    What the other modules give is flexibility to check the emails that are being sent e.g. by forwarding to another address. The patch here discards all emails, which is not necessarily very helpful for being able to test. The other modules already have a community and provide a useful solution. Enhancing them to work with this module seems like the right solution, and it shouldn't be difficult. What is the disadvantage of that???

    The patch on πŸ› No mail with symfony_mailer Needs work seems like the wrong approach - as you say it requires adding an adjuster. Presumably the module previously used hook_mail_alter() and it should now use the new hooks and throw a SkipSending.

    A config override that is the same for all dev environments, and simply auditable

    Probably not really.

  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    > What the other modules give is flexibility to check the emails that are being sent e.g. by forwarding to another address.
    > Enhancing [the other modules] to work with this module seems like the right solution, and it shouldn't be difficult. What is the disadvantage of that???

    Yes i can follow that reasoning and work in that direction. Then we can close this. Or better postpone and crosslink the related, so that others will not open new issues, but collaborate over there. Your choice. (Added googlefood).

  • πŸ‡¬πŸ‡§United Kingdom AdamPS

    I think this is a duplicate of ✨ Support for Reroute Email Closed: won't fix so we should close one of them, and copy across any important information into the other. The other issue came first and has more followers, so it seems natural to make this one the duplicate.

  • πŸ‡³πŸ‡΄Norway eiriksm Norway

    Also interested.

    My use case is different though. I need the regular nail manager to be in use in CI, since my tests are setting the mail interface class. Since symfony mailer is replacing the plugin manager, I would like the kill switch to just not replace anything in the service provider

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 10 months ago
    6 pass
  • @eiriksm opened merge request.
  • πŸ‡³πŸ‡΄Norway eiriksm Norway

    Opened a MR with a completely backwards compatible solution that totally disabled symfony mailer with a service container parameter.

    To use, add something like this to your services.yml (or you can even have it in a module service.yml I guess)

    parameters:
      symfony_mailer.disabled: true
  • πŸ‡³πŸ‡΄Norway eiriksm Norway
  • πŸ‡ΊπŸ‡¦Ukraine bohart Lutsk, Ukraine

    Reroute email module now supports Drupal Symfony Mailer module: https://www.drupal.org/project/reroute_email β†’ (2.3.x versions)

    Once the issue ✨ Allow removal of to/cc/bcc/reply-to addresses (after they are added to an email) Needs work is a part of the next Drupal Symfony Mailer release, Reroute email module will have a new stable release with full support.

    So, the site owners can enable and configure it for not sending (or rerouting) any emails from all instances (except the live instance, for example).

    Hope this update/comment helps!

  • Status changed to Closed: won't fix 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom AdamPS

    Great thanks @bohart I'll get onto the other issue

    Not sure whether to mark this as fixed, but "won't fix" is probably more accurate.

    I added a ref to Reroute Email in the FAQ https://www.drupal.org/docs/contributed-modules/drupal-symfony-mailer/fa... β†’

  • πŸ‡ΊπŸ‡ΈUnited States NicholasS

    Wanting to switch to symphony mailer, but also need the same features discussed here that mail_safety provided.

    • Ability to disable all outgoing mail, the web UI checkbox is great for debugging smtp issues on dev
    • The dashboard or outgoing mail log of mail_safety is also a hard requirement.
    • mail safety also allows overriding and resending using the dashboard/log also handy.

    For me the reroute email isn't ideal as I don't think ill be able to verify the To: is accurate in my dashboard/logs.

  • +1 to NicholasS - I'd rather use symfony_mailer, but this issue might mean we have to use https://www.drupal.org/project/symfony_mailer_lite β†’ and keep using mailsystem etc.

Production build 0.69.0 2024