Skip to main content
Topic: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted (Read 3516 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

I'm not really sure what to make of this, but Gmail seems to be refusing emails. Does anybody know what's up with that? I've got all of the DKIM/SPF/DMARC stuff set up.

Code: [Select]
Messages with multiple addresses in From:n550 5.7.1 header are not accepted. 

https://serverfault.com/questions/841465/rejected-emails-messages-with-multiple-addresses-in-from-header-are-not-accept

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #1

The easy fix is to only set one email address in the from header. That should be the standard anyway looking at the RFC.

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #2

Let me try to partially rephrase: Elkarte emails are being bounced and Wordpress emails are not. Both are using PHP to send emails. How can I tell Elkarte to set only one email address in the from header? There is no such setting in Maintenance → Mail → Settings.

The settings search does indeed hint at the existence of a "Reply-To and From email address [Setting] " but ?action=admin;area=maillist;sa=emailsettings just opens the main admin page. I suspect it's related to Post by Email Management.

Edit: there's also $webmaster_email in Settings.php as well as Configuration → General → Webmaster email address. This points to an email address on the domain.
Last Edit: March 22, 2022, 12:39:11 pm by Frenzie

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #3

Could you post a raw .eml file of what is being sent so I can take a look ?

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #4

Also any chance you can try SMTP as well and see if the error repeats with that transport?

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #5

I don't know what it looks like to Google of course, but:
Code: [Select]
Return-Path: <thefromemail@dndsanctuary.eu>
Received: from www354.your-server.de
by www354.your-server.de with LMTP
id sPIUL87KOmKkIAAA/Nz4eQ
(envelope-from <thefromemail@dndsanctuary.eu>); Wed, 23 Mar 2022 08:22:54 +0100
Envelope-to: justforsometesting@dndsanctuary.eu
Delivery-date: Wed, 23 Mar 2022 08:22:54 +0100
Received: from localhost ([127.0.0.1] helo=www354.your-server.de)
by www354.your-server.de with esmtps (TLSv1.3:TLS_AES_256_GCM_SHA384:256)
(Exim 4.92.3)
(envelope-from <thefromemail@dndsanctuary.eu>)
id 1nWvKY-0002VL-Oy
for justforsometesting@dndsanctuary.eu; Wed, 23 Mar 2022 08:22:54 +0100
To: justforsometesting@dndsanctuary.eu
Subject: Welcome to The DnD Sanctuary
From: "The DnD Sanctuary" <thefromemail@dndsanctuary.eu>
 Return-Path: thefromemail@dndsanctuary.eu
 Date: Wed, 23 Mar 2022 07:22:54 -0000
 X-Mailer: ELK
 Mime-Version: 1.0
 Content-Type: multipart/alternative; boundary="ELK-83f0fe058f0cf03cf18bffd39d24f144"
 Content-Transfer-Encoding: 7bit
 Message-ID: <b9d5348f83cc8893f56575710c4291cb-@dndsanctuary.eu>
Message-Id: <E1nWvKY-0002VG-N5@www354.your-server.de>
Date: Wed, 23 Mar 2022 08:22:54 +0100

I'll try SMTP later.

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #6

Hm, so in Vivaldi it just shows

QuoteFrom: The DnD Sanctuary <etc>

But in Thunderbird it says:


Clicking on "2 more" shows the other supposed from addresses are:
Code: [Select]
multipart/alternative <>

And:
Code: [Select]
the-message-id-hash@dndsanctuary.eu

It's likely Gmail parses it the same way, but then decides to reject the message.



Edit: the one from Wordpress looks like this:

Code: [Select]
…@gmail.com; Mon, 21 Mar 2022 20:11:30 +0100
To: …@gmail.com
Subject: Site nonsense
Date: Mon, 21 Mar 2022 19:11:30 +0000
From: WordPress <…@…>
Message-ID: <3gsjHp42Em8qSFqoTD8HHjC7ltZYffugefPCV0f8tE@fransdejonge.com>
X-Mailer: PHPMailer 6.5.3 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8

I don't know the email header spec but that indentation in the email from Elkarte looks suspicious?


Edit 2:

In any case, running it through a header parser shows this is indeed the entire from field:

Code: [Select]
"The DnD Sanctuary" <thefromemail@dndsanctuary.eu> Return-Path: thefromemail@dndsanctuary.eu Date: Wed, 23 Mar 2022 07:22:54 -0000 X-Mailer: ELK Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="ELK-83f0fe058f0cf03cf18bffd39d24f144" Content-Transfer-Encoding: 7bit Message-ID: <b9d5348f83cc8893f56575710c4291cb-@dndsanctuary.eu>

Removing the single-space indentation seems to result in correct parsing.
Last Edit: March 23, 2022, 04:04:29 am by Frenzie

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #7

If you would be so kind as to try something quick, this is a bug I found when I redid the entire mail sending function in 2.0.  I have this change slated for 1.1.9 as well.

In your Mail.subs.php file
Code: (find) [Select]
	// Return path, date, mailer
$headers .= 'Return-Path: ' . $return_path . $line_break;

Code: (replace) [Select]
	// Return path, date, mailer
if ($use_sendmail)
$headers .= 'Return-Path: <' . $return_path . '>' . $line_break;

Lets see if that fixes the issue for you.

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #8

Same bounce error from Gmail I'm afraid. Glancing at the code there it's a complete mystery to me where that single-space indentation could be coming from.

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #9

@Spuds It works when you always use \r\n

Code: (find) [Select]
$line_break = detectServer()->is('windows') || !$use_sendmail ? "\r\n" : "\n";

Code: (replace) [Select]
$line_break = "\r\n";

In other words, this comment right above appears to be false:
Code: [Select]
// Line breaks need to be \r\n only in windows or for SMTP.

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #10

It looks like the current behavior is plainly incorrect:
Quote from: https://www.php.net/manual/en/function.mail.phpMultiple extra headers should be separated with a CRLF (\r\n).

But there is this note:
QuoteNote:

If messages are not received, try using a LF (\n) only. Some Unix mail transfer agents (most notably » qmail) replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #11

Good detective work :D

I do remember that now ... I came across that when I was redoing things for 2.0 and did the same lookup on php.net and thought that was strange.

Then as I did some more digging, it seems that PHP mail() talks to the native sendmail command of the OS, which should expect line endings to OS native line endings  ... LF (\n) on Unix/Linux and CRLF (\r\n) on Windows. 
SMTP always wants CRLF but that is a lot different than native sendmail. 
So what I'm saying is I feel the PHP net documentation may be misleading, other than maybe the qmail stuff?

Its a bit of a mystery, are you running on *nix or *doz ?

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #12

Windows is a logical impossibility, 'cause then the issue wouldn't have occurred on account of that line. ;)

Quote from: Spuds – So what I'm saying is I feel the PHP net documentation may be misleading, other than maybe the qmail stuff?

I feel that it's not misleading because if it were the issue wouldn't have occurred. :P

Also the PHP documentation is definitely not written Windows-first.

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #13

There are some Windows-only notes too btw. The \r\n thing definitely isn't one of those.

Incidentally, this comment seems to explain the behavior, although it simultaneously contradicts it:

QuoteSecurity advice: Although it is not documented, for the parameters $to and $subject the mail() function changes at least \r and \n to space. So these parameters are safe against injection of additional headers. But you might want to check $to for commas as these separate multiple addresses and you might not want to send to more than one recipient.

The crucial part is the $additional_headers parameter. This parameter can't be cleaned by the mail() function. So it is up to you to prevent unwanted \r or \n to be inserted into the values you put in there. Otherwise you just created a potential spam distributor.

That might indicate it's new, for some value of new for a PHP release after December of 2016, anyway. But it might explain the odd single-space indentation.

Additionally, it's only been a few years that Gmail has started showcasing this bouncing behavior, so it would've been mostly irrelevant in the past.
Last Edit: March 23, 2022, 05:43:41 pm by Frenzie

Re: Gmail: multiple addresses in From:n550 5.7.1 header are not accepted

Reply #14

I was just curious if you were running something like Xampp, or other,  stack on windows, these can do some odd things.

I looked at the "ancestry" and the CRLF vs LF has been that way for ~15 years, it is not something new in Elk  Going back even further it looks like it was CRLF back when php4 was a thing.   If I change it to CRLF the mail tests fail in our github actions testbed which is Ubuntu 20.04, so at least Ubuntu/Debian native sendmail expect only LF. 

So what OS are you  running ? Have you specified anything different in your php.ini mail settings where it may be using SMTP instead of sendmail ?