Sender not added as MailboxHeader but is valid Address

Created on 9 January 2024, about 1 year ago
Updated 1 February 2024, 12 months ago

Just want to say, this module made our D10 upgrade so much easier, so thanks...!

Problem/Motivation

The string of the kind "Students Union UCL <info@studentsunionucl.org>" cannot be added as the Sender without this error being triggered:

An attempt to send an e-mail message failed, and the following error message was returned : The "Sender" header must be an instance of "Symfony\Component\Mime\Header\MailboxHeader" (got "Symfony\Component\Mime\Header\UnstructuredHeader").

This is because the isMailboxHeader function validates the $value as whether it is a valid e-mail or not, whereas the Sender header can be either an e-mail address or something that can be an Symfony\Component\Mime\Address (which could be not just a valid e-mail). Basically, the validation is filtering out valid inputs because it is assuming Address requires a valid e-mail.

In any case, adding sender as a Text header when it cannot be added as a MailboxHeader will always fail to send the e-mail, so perhaps an error should be thrown earlier by symfony_mailer_lite - not sure.

Steps to reproduce

Try to send an e-mail with "Students Union UCL <info@studentsunionucl.org>" as the Sender header, going in to SymfonyMailer::mail()

Note Webform may be a trigger as noted by @interX - "because webform reuses the From-header as Sender, and that often is Mailbox-format and not a simple address"

Proposed resolution

See branch/merge request. This modifies isMailboxHeader to validate either by e-mail or if that fails by trying to create an Address object.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024