Add EmailAdjuster to use primary from as sender

Created on 5 February 2024, 5 months ago
Updated 14 April 2024, 2 months ago

Problem/Motivation

When using drupal/symfony_mailer, the sender is by default set as the site email. This is a change in behavior compared to the deprecated drupal/swiftmailer, where the sender matched the from address.

Steps to reproduce

Using webform:
- Install webform and symfony_mailer
- Create a webform with a mail handler, set from to a different address than site address
- Send an email and compare Envelope "MAIL FROM" and Header "From". They will not match, "MAIL FROM" is the site email, "From" is the address set in the webform mail handler.

Proposed resolution

- Add an EmailAdjuster plugin that sets the "MAIL FROM" based on the FROM information. This adjuster can be activated for specific mailer policies.

Remaining tasks

- Add tests

User interface changes

- Adds an additional EmailAdjuster for symfony mailer

API changes

- Adds an additional EmailAdjuster for symfony mailer

Data model changes

πŸ“Œ Task
Status

Needs work

Version

1.4

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland pvbergen

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

Merge Requests

Comments & Activities

  • Issue created by @pvbergen
  • Merge request !397Draft: Add EmailAdjuster β†’ (Closed) created by pvbergen
  • Pipeline finished with Canceled
    5 months ago
    #87740
  • Pipeline finished with Success
    5 months ago
    Total: 1987s
    #87741
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
  • πŸ‡¨πŸ‡­Switzerland pvbergen

    @jrockowitz
    I'm a bit unsure with symfony_mailer, so I can't tell, what approach is best.

    Thinking about it, I realize that my adjuster should go into drupal/symfony_mailer.
    It just takes the first from address and sets it as a sender, which might be a broader use case.
    The WebformEmailBuilder from #3260134 should go into drupal/webform, as it is opinionated towards webform.

    I adjusted this issue to be in Symfony Mailer.

  • Merge request !86Add adjuster to set from as sender β†’ (Open) created by pvbergen
  • Pipeline finished with Success
    5 months ago
    Total: 201s
    #89831
  • πŸ‡¨πŸ‡­Switzerland pvbergen
  • Status changed to Postponed: needs info 5 months ago
  • πŸ‡¬πŸ‡§United Kingdom AdamPS

    AFAICS Core MailManager sets Sender to site mail. I can't find any reference to Sender in swiftmailer.

    This issue similar to ✨ Allow to customize Sender Active , especially see #2 for explanation of why in general it's not a good idea to set sender based on from.

  • Status changed to Needs review 5 months ago
  • πŸ‡¨πŸ‡­Switzerland pvbergen

    @AdamPS:
    Thanks for the feedback. I didn't see #3388651 before but I also think it addresses another, more global request.

    Using this adjuster would allow finegrained control which mails the sender should be overwritten for.
    This would leave the default implementation with their valid concerns unaffected while still allowing site builders to specifically select exceptions.

    We often have projects where we use different sender addresses (using the same domain) on webforms becaus of (strong) client request and this would allow us to fulfill this request without custom code. I also argue that webform mails are not in the same class as general site notifications and can fulfill very different purposes.

    Sidenote: Fixed the typo in my class.

  • Pipeline finished with Success
    5 months ago
    Total: 171s
    #94000
  • πŸ‡¬πŸ‡§United Kingdom AdamPS

    Thanks for the update - I understand your point however it's not the same as the original ISπŸ˜ƒ.

    As you say this seems like a bit of a specialised situation. I am concerned that many simple site-owners could be confused by this adjuster and perhaps use it incorrectly causing their emails to bounce. Perhaps it belongs back in Webform module after all??

  • πŸ‡¨πŸ‡­Switzerland pvbergen

    Updated title, IS

  • πŸ‡¨πŸ‡­Switzerland pvbergen
  • πŸ‡¬πŸ‡§United Kingdom AdamPS

    ✨ Allow to customize Sender Active seems like a better UX to me. What do you think?

  • Status changed to Needs work 2 months ago
  • πŸ‡¬πŸ‡§United Kingdom AdamPS

    Or we could add a setting on from adjuster "also use as sender" (causes error if there is more than one from)?

    I propose we should have a description that explains:
    - by default the sender address comes from "Basic site settings" and normally you wouldn't change it
    - ensure this server is authorised to send from the specified address to help prevent emails being flagged as spam

Production build 0.69.0 2024