- Issue created by @adamps
- 🇨🇭Switzerland berdir Switzerland
Note that my thoughts on this are in the meta issue 🌱 [META] Adopt the symfony mailer component Needs review , comment #89 and #93. IMHO that discussion fits into the meta issue and the proposal here doesn't quite match my proposal. If we do want to move it here then it should imho summarize the different approaches that have already been discussed over there.
- 🇬🇧United Kingdom catch
Coming from #3380476-5: Change core modules to use Symfony Mailer → .
When we commit this issue, that means Core modules switch to the new API for sending mails. We don't need 'if (new mail system)' or any code calling MailManagerInterface. However we must keep the same contents of emails sent and still call hook_mail_alter() with an old style $message array.
This is where I get a bit lost, but I think it means this:
1. Core modules define e-mails with both hook_mail_alter() and the new message templates, so we have duplicate e-mail definitions until we drop the old ones - which is the change in ✨ Change core modules to use Symfony Mailer Active .
2. Sites can then opt-in to sending e-mails generated with the new message templates instead of hook_mail()/hook_mail_alter().
For #2 to work, contrib modules that alter emails need to have been updated so they handle both approaches.
However contrib modules that define e-mails may or may not have been updated at this point - if they only have the new message templates, those will be used, if they define both, the new message templates will be used, but if they only implement hook_mail(), we'll detect this and fall back to that for the specific module.
I think that can work to allow everything to move at different times, the cost is keeping duplicates of e-mails definitions until Drupal 11 but they don't change often anyway.
That leaves one more case though:
What happens when a contrib module only defines e-mails using the new API (say because it's a brand new module) and not hook_mail(), and a site is still configured to send hook_mail() e-mails by default, would we 'fall forwards' to the template e-mails in that case?
And then I guess in Drupal 11 we force everything to use the new system everywhere and drop hook_mail().
- 🇬🇧United Kingdom adamps
@Berdir
the proposal here doesn't quite match my proposal
I read your proposal carefully, and I believe I'm pretty close to it. I have included a global feature flag as you suggested.
I made one deliberate change because I thought it wouldn't work otherwise. I also added a per-module flag. That's because often a contrib will module adds support for the new API in a patch version. If a site has the global feature flag enabled, then suddenly emails from this module will switch to use the new API without any warning/control. However the site might have hooks for that module using the old
hook_mail_alter()
. Does that make sense to you?Any other differences from your proposal are because I didn't understand what you meant. Also some of the details are likely not entirely right however it should become clearer once we have other pieces in place.
===
@catch very good summary thank you.
What happens when a contrib module only defines e-mails using the new API
My idea is that the mailer can automatically map to the old API. The interfaces are pretty similar.
- 🇬🇧United Kingdom adamps
Issue summary updated. Now simpler, closer to suggestion from Berdir, and explained in a lot more detail.