Problem/Motivation
On Drupal 11.2 and later (possibly earlier versions too), the MailManager service defined by easy_email_override doesn't actually work. :(
If you try to get an instance -- or even the definition -- of the php_mail backend built into core, it won't find it. Why? Because core now uses attributes, not annotations, for mail backend discovery...but that means the MailManager decorator isn't passing the proper constructor arguments to the parent, which would allow it to locate the #[Mail] attribute.
Steps to reproduce
With easy_email_override installed, try this at drush php:
Drupal::service('plugin.manager.mail')->getDefinition('php_mail');
It'll throw.
Proposed resolution
There are two ways here: the quick way (one line) and the thorough way (which I did).
- The quick way: just pass the proper plugin attribute class to
parent::__construct()so that attribute-based mail backends will be found. - The thorough way: remove any need to call the parent constructor, by decorating the plugin manager properly instead of halfway overriding it by way of
DefaultPluginManager. I think this way is preferable because, although it's more verbose, it's completely impervious to any future constructor changes that take place in the parent class. This is a stronger choice for backwards compatibility.
This is unfortunately a critical Drupal CMS issue, as it breaks site templates -- detailed in #3556992: The site:export command mistakenly exports specific pre-existing user roles and simple config.
Issue fork easy_email-3557052
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
phenaproximaComment #4
zengenuity commentedMerged and released in 3.0.7.