Add support form DKIM signing

Created on 27 February 2024, 4 months ago
Updated 28 February 2024, 4 months ago

Problem/Motivation

https://symfony.com/blog/new-in-symfony-5-2-dkim-email-authentication

https://symfony.com/doc/6.3/mailer.html#dkim-signer

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary mxr576 Hungary

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

Comments & Activities

  • 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
  • πŸ‡­πŸ‡Ί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...

  • πŸ‡ΊπŸ‡Έ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...

Production build 0.69.0 2024