Page MenuHomePhabricator

mutiple headers in emails from UserMailer
Closed, ResolvedPublic

Description

From some examples:

To: mah@everybody.org
Subject: Wikipedia e-mail from user "MarkAHershberger"
From: MarkAHershberger <mah@everybody.org>
To: MarkAHershberger <mah@everybody.org>
Subject: Wikipedia e-mail from user "MarkAHershberger"

To: mah@everybody.org
Subject: Copy of your message to Saibo: Wikipedia e-mail from user "MarkAHershberger"
From: MarkAHershberger <mah@everybody.org>
To: MarkAHershberger <mah@everybody.org>
Subject: Copy of your message to Saibo: Wikipedia e-mail from user "MarkAHershberger"

Two "To:" and "Subject:" headers


Version: 1.19
Severity: normal

Details

Reference
bz34421

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 12:16 AM
bzimport set Reference to bz34421.

mmovchin wrote:

I'm sorry, I couldn't reproduce it. The Mail Header I got:

Return-Path: <wiki@wikimedia.org>
Delivery-Date: Sun, 12 Feb 2012 16:39:24 +0100
Received: from wiki-mail.wikimedia.org (wiki-mail.wikimedia.org [208.80.152.133])
by xxxxxxxxxxx (node=mxeu2) with ESMTP (Nemesis)
id xxxxxxxxxxx for michael@movchin.de; Sun, 12 Feb 2012 16:39:24 +0100
Received: from mw4.pmtpa.wmnet ([10.0.11.4]:38825)
by mchenry.wikimedia.org with esmtp (Exim 4.69)
(envelope-from <wiki@wikimedia.org>)
id xxxxxxxxxxx
for michael@movchin.de; Sun, 12 Feb 2012 15:39:23 +0000
Received: from apache by mw4.pmtpa.wmnet with local (Exim 4.71)
id xxxxxxxxxxx
for michael@movchin.de; Sun, 12 Feb 2012 15:39:23 +0000
Date: Sun, 12 Feb 2012 15:39:23 +0000
Message-Id: <xxxxxxxxxxx@mw4.pmtpa.wmnet>
To: Mmovchin <michael@movchin.de>
Subject: Wikipedia-E-Mail
MIME-Version: 1.0
Content-type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Mailer: MediaWiki mailer
From: xxxxxxxxxxx <xxxxxxxxxxx@xxxxx.xx>
Envelope-To: michael@movchin.de

this was on test2, so it is the not-yet-released 1.19 software

  • Bug 34435 has been marked as a duplicate of this bug. ***

I do confirm this issue. marking for 1.19 deployement.

I have bisected the issue to includes/UserMailer.php at revision r93397 by mah who is also the reporter of this bug :-)

At previous r93279 we have no issue.

I am not taking the bug per see right now. If I do I will assign it to myself. So feel free to fix the issue :-)

I'm guessing that this is caused by setting $headers['To'] instead of changing mail's first parameter (recipient/to).

  • Bug 34464 has been marked as a duplicate of this bug. ***

subject header dealt with r111765

The To: header need a bit more investigation. Will attempt to poke at it tonight.

Created attachment 10032
To header patch

I'm completely new to this so forgive me if I'm doing something wrong here, but I think I fixed the To header. It appears to work on my local setup without $wgSMTP.

attachment url.txt ignored as obsolete

sumanah wrote:

Thanks for the patch, Alex! I added

need-review

and

patch

as keywords here to indicate that you've attached a patch that needs review. Hope to get a developer to review this soon. Thanks again!

Created attachment 10034
Actual patch

So AttachURL didn't quite work how I was expecting. This should be the actual patch.

attachment MWUserMailer.patch ignored as obsolete

  • Bug 34479 has been marked as a duplicate of this bug. ***

Created attachment 10036
Previous patch + PEAR Subject header fix.

r111765 broke the Subject header when using PEAR, so this patch does the same thing as my last one, but *should* (untested) fix that.

Attached:

Alex: thanks for your patches, that gave me some ideas to properly fix this issue. I have send the change as r111832. Comments inside the source code give some explanations.

To: and Subject: headers need to be handled differently depending upon the mailer we are going to use.

To:

PHP mail() first argument is the mail receiver. The argument is used as a recipient destination and as a To header.

PEAR mailer has a recipient argument which is only used to send the mail. If no To header is given, PEAR will set it to to 'undisclosed-recipients:'.

NOTE: To: is for presentation, the actual recipient is specified by the mailer using the Rcpt-To: header.

Subject: PHP mail() second argument to pass the subject, passing a Subject
as an additional header will result in a duplicate header.

PEAR mailer should be passed a Subject header.

With r111832, mails sent to a single recipients will look alike with mail() or PEAR Mail.
For multiple recipients:

  • php mail() will show the recipient email and 'undisclosed-recipients:'
  • PEAR Mail will only show 'undisclosed-recipients:'