Problem/Motivation
First of all, this is not a dupe of #3299164: Token error - does not comply with addr-spec of RFC 2822 ;) A random test of the contact webform on our new website failed due to "Email does not comply with addr-spec of RFC 2822" error.
On investigating the problem, I've seen that this "From" header was set on the message:
"DDr. Mag. Maximilian Gustavo Mustermann-Garcia, PhD, LMAA"
which should be fine - however the error log showed only the name part in its message:
Email ""DDr. Mag. Maximilian Gustavo Mustermann-Garcia" does not comply with addr-spec of RFC 2822
So obviously, the e-mail part gets cut off here.
On further investigation, I've seen that core already has fixed the same problem here: #3226117: Uncaught RfcComplianceException when email From name contains a comma
Steps to reproduce
Configure a webform with a "name" field and configure an e-mail handler, using this token as "From" address: [name] <[site:mail]>
I've also disabled symfony_mailer and let core send the same e-mail - and it worked (the mentioned core issue is already fixed, as oyu can see)
Proposed resolution
The problem should lie inside MailerHelper::parseAddress() imho. However, replacing explode(',', $encoded) with str_getcsv() like core did, seems not do solve the problem. I guess, this change would be necessary as well, but also there might be a problem with the self::FROM_STRING_PATTERN too.. However I couldn't figure it out, was already happy to find this place, when I was already a bit lost inside the symfony_mailer codebase :D But this should be a good starting point for the maintainer, hopefully :)
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork symfony_mailer-3377649
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 #2
agoradesign commentedPS: I'm using 1.2.2
Comment #3
adamps commentedLooks like a duplicate of #3350992: Add support for complex address strings in back-compatibility mode
Comment #4
agoradesign commentedagree ;)