Needs review
Project:
Mail Safety
Version:
2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Mar 2022 at 13:50 UTC
Updated:
12 Sep 2025 at 07:12 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
trickfun commentedHi,
no feedback ?
is project alive?
Comment #3
sjerdoIt seems like module symfony_mailer bypasses the Drupal mail system. As a result the implemented hook `hook_mail_alter` of the Mail Safety has no effect when using the Symfony mailer..
Sub-module symfony_mailer_bc stops sending the mail if
$message['send']is set tofalse: https://git.drupalcode.org/project/symfony_mailer/-/blob/1.x/modules/sym...For symfony_mailer it seems like we need to implement hook_mailer_PHASE and throw a SkipMailException or use the email_skip_sending mail adjuster like
Drupal::service('plugin.manager.email_adjuster')->createInstance('email_skip_sending', $config)->init($email);Comment #4
trickfun commentedHi sjerdo,
any news?
the module is unusable now.
do you have a problem resolution date?
thank you in advance
Comment #5
miguel.leal commentedUsing sjerdo directions I think we can use an adjuster for a temporary solution.
Comment #6
seogow commentedHere is a slightly updated Miguel's snippet, which works with Symfony mailer 1.x-dev. It may worth to just include it into 'mail_safety' when reviewed?
To use, you need to:
Comment #7
miguel.leal commentedseogow, i appreciate your update, but on my side (at least for 1.0 alpha), i can't interact and set a new address during the postRender, so I'm still using a build method. And also the getFrom() is always empty for me.
Anyway, not sure if this will be used like that when mail safety became ready with symfony mailer, however, this workaround can be easier to use as a patch.
In the end as already mentioned, this adjuster 'Mail Safety' can to be enabled on the symfony mailer policy for *All* (/admin/config/system/mailer).
Comment #8
trickfun commentedPatch doesn't work.
Dashboard is always empty.
Thank you
Comment #9
trickfun commentedAny news for this patch?
Thank you
Comment #10
trickfun commentedI fix the patch.
Some wrong if conditions preventing save messages into mail safety table.
Comment #11
trickfun commentedComment #12
trickfun commentedthis is the patch for 8.2 version
Comment #13
trickfun commentedSorry, the patch is wrong.
this is the right, i hope
Comment #14
flyke commentedI can conform this works on 8.x-1.2
- Apply patch
- Clear caches (drush cr)
- Visit Settings > System > Mailer (/admin/config/system/mailer)
- Edit *All* (/admin/config/system/mailer/policy/_)
- From the dropdown, select 'Mail Safety' and add it
Comment #15
agogo commentedThanks for the patch! Also works with 2.0. (#13)
A small note is that the patch forces all mails to not be sent when not using a/the default mail address by setting setTransportDsn as null. I had to make a copy of the patch and remove that part (+ the setReplyTo setting that is there for some reason).
Comment #16
geek-merlinThanks for the patch, it is a valuable POC. Also for #15.
The adjuster approach has the downside though, that i must add an adjuster.
What i want as a site owner is sth like a simple config override setting to set in all dev environments and when i see that setting, i have no fear that a customer gets an ouch mail (which is the promise of this module).
Maybe leveraging hook_mailer_alter helps here.
Comment #17
geek-merlinFeedback from AdamPS (Maintainer of Drupal Symfony Mailer) in the related issue:
Comment #18
msutharsI'm using the following snippet:
Comment #19
drunxfish commentedComment #21
drunxfish commentedImplemented solution, everything is in order, however needs a review!