- Issue created by @mxr576
- ππΊHungary mxr576 Hungary
Perhaps the most straightforward approach to address this kind of feature request would be to trigger an event before the email is handed over to the mailer. This could potentially be achieved by adding an event listener at this point in the code: [link to the specific line of code](https://git.drupalcode.org/project/symfony_mailer_lite/-/blob/1.0.5/src/...).
Such an event could provide an opportunity for contrib modules to extend the functionality of this "lite" solution without significantly increasing its weight.
- ππΊHungary mxr576 Hungary
Maybe a poor man's solution could be today decorating the
symfony_mailer_lite.mailer
service and forcing DKIM signing in the decorator on all outgoing emails. - πΊπΈUnited States zengenuity
We had a similar request over here: π Created transports can not be altered Fixed
Does the solution that @Bedir is using work for what you need to do as well?
- Assigned to mxr576
- ππΊHungary mxr576 Hungary
Interesting approach, tbh, I haven't spent enough to investigate that solution because I was using the source of the latest stable release... and I found this line in the official mailer doc:
Signing and encrypting messages require their contents to be fully rendered. For example, the content of templated emails is rendered by a MessageListener. So, if you want to sign and/or encrypt such a message, you need to do it in a MessageEvent listener run after it (you need to set a negative priority to your listener).
which was very much aligned in my original idea described in [#3424075#comment-15464196]. So Symfony Mailer library fires a MessageEvent and that could/should be used for this purpose, the only reason why this event is not fired, because the event dispatcher is nod passed to transports built by this module.
I can try to fix that as a first step.
- Issue was unassigned.
- ππΊHungary mxr576 Hungary
Ahh, so now that fromStrings() is used instead of fromDsns(), there is no way to pass the event dispatcher... :(
https://git.drupalcode.org/project/symfony_mailer_lite/-/commit/7fca72eb...
- ππΊHungary mxr576 Hungary
Also opened: https://github.com/symfony/symfony/issues/54098
- πΊπΈUnited States zengenuity
We tried to add this here: β¨ Symfony mailer transports are unable to to dispatch events Needs review
We merged that after the other issue, but does it not work? I don't have an advanced use case where I've been able to test it out myself.
- ππΊHungary mxr576 Hungary
:facepalm: The project that I used for checking has an older stable version, not the latest one which is also up to date with master... sorry, you are right, that event is already fired, even with the fromString() approach, at least with the Sendmail transport...
So this may means that the fundamentals for performing DKIM signing in a custom/contrib module are in place...