I'm having an issue where google keeps bouncing my emails coming from a Drupal site.
This is the reported error:
Messages with multiple addresses in From: 550 5.7.1 header are not accepted.
This is coming from a password reset email and it's simply using Drupal's built-in mail management.
The problem turns out out to be that the site name has a comma in it and google's mail server is reading the From address in the header as multiple addresses.
e.g.
From: Site Name, Inc. <admin@example.com>
I made a fix for this that involves adding quotes around the name so that any commas within are treated as text.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | email-from-header-2898750-8.patch | 1.71 KB | msankhala |
| #6 | from-email-2898750-6.patch | 1.69 KB | jody lynn |
| #4 | email_from_header-2898750-4.patch | 2.02 KB | sjerdo |
| multiple_email_from_header.patch | 719 bytes | kleinmp |
Comments
Comment #3
echoz commentedThanks, this confirmed the same problem for me of email sent to gmail from a site name with an apostrophe.
Comment #4
sjerdoThis error not only seems to occur with commas. When a site name contains ", ' or < followed by >, it also isn't allowed.
We should add quotes around the name and escape double quotes.
I have added a patch which escapes double quotes. I have also updated the test.
Comment #6
jody lynnRerolled patch as it no longer applies on 8.4
Comment #8
msankhala commentedPatch rerolled.
Comment #10
longwaveI am not sure this is the right fix, as shown by the tests this would appear to corrupt MIME encoded headers - according to the spec it looks like these should not be quoted. http://www.rfc-editor.org/rfc/rfc2047.txt says
We can either special-case the result of Unicode::mimeHeaderEncode when it comes back unchanged but the string still contains unwanted characters, or maybe Unicode::mimeHeaderEncode needs extending to consider encoding the unwanted characters as well. Right now it assumes the entire ASCII set is valid.
Comment #11
allella commentedThis bug got me on two D8 installs with commas in the sitename.
#10 / longwave made the point of where to fix the issue.
1) Within Unicode::mimeHeaderEncode()
or
2) Within MailManager doMail()
RFC2047 is focused on "textual header information in character sets other than US-ASCII" and the MIME standards all seem to address non-ASCII formats so tampering with mimeHeaderEncode() seems inappropriate since the method and the RFC it references are geared to non-ASCII. So, this would mean a fix that involves doMail().
Should we do a variation of longwave's suggestion
or a variation
This also begs the question of if the $reply variable in doMail() also needs to get the same treatment as the From because Reply-To also allows for a name portion before the email address.
Comment #12
allella commentedComment #13
allella commentedThis issue isn't limited to just Google/Gmail. Any RFC valid email receiver would have the issue.
Closing this as a duplicate since more recent conversations were had on an issue that's tagged as Major and "mail system"
https://www.drupal.org/project/drupal/issues/2745039