Last modified: 2012-05-03 02:42:50 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 34421 - mutiple headers in emails from UserMailer
mutiple headers in emails from UserMailer
Product: MediaWiki
Classification: Unclassified
Email (Other open bugs)
All All
: High normal (vote)
: 1.19.0 release
Assigned To: Antoine "hashar" Musso (WMF)
: patch, patch-need-review, platformeng
: 34435 34464 34479 (view as bug list)
Depends on:
Blocks: 31217
  Show dependency treegraph
Reported: 2012-02-15 18:12 UTC by Mark A. Hershberger
Modified: 2012-05-03 02:42 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

To header patch (38 bytes, text/plain)
2012-02-17 19:00 UTC, Alex Monk
Actual patch (732 bytes, patch)
2012-02-17 19:14 UTC, Alex Monk
Previous patch + PEAR Subject header fix. (985 bytes, patch)
2012-02-17 22:20 UTC, Alex Monk

Description Mark A. Hershberger 2012-02-15 18:12:07 UTC
From some examples:

Subject: Wikipedia e-mail from user "MarkAHershberger"
From: MarkAHershberger <>
To: MarkAHershberger <>
Subject: Wikipedia e-mail from user "MarkAHershberger"

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

Two "To:" and "Subject:" headers
Comment 1 Michael Movchin 2012-02-15 18:30:52 UTC
I'm sorry, I couldn't reproduce it. The Mail Header I got:

Return-Path: <>
Delivery-Date: Sun, 12 Feb 2012 16:39:24 +0100
Received: from ( [])
	by xxxxxxxxxxx (node=mxeu2) with ESMTP (Nemesis)
	id xxxxxxxxxxx for; Sun, 12 Feb 2012 16:39:24 +0100
Received: from mw4.pmtpa.wmnet ([]:38825)
	by with esmtp (Exim 4.69)
	(envelope-from <>)
	id xxxxxxxxxxx
	for; Sun, 12 Feb 2012 15:39:23 +0000
Received: from apache by mw4.pmtpa.wmnet with local (Exim 4.71)
	id xxxxxxxxxxx
	for; 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 <>
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>
Comment 2 Mark A. Hershberger 2012-02-15 19:09:54 UTC
this was on test2, so it is the not-yet-released 1.19 software
Comment 3 Max Semenik 2012-02-16 10:46:41 UTC
*** Bug 34435 has been marked as a duplicate of this bug. ***
Comment 4 Antoine "hashar" Musso (WMF) 2012-02-16 16:38:19 UTC
I do confirm this issue. marking for 1.19 deployement.
Comment 5 Antoine "hashar" Musso (WMF) 2012-02-16 16:55:26 UTC
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.
Comment 6 Antoine "hashar" Musso (WMF) 2012-02-16 17:00:01 UTC
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 :-)
Comment 7 Alex Monk 2012-02-16 17:07:23 UTC
I'm guessing that this is caused by setting $headers['To'] instead of changing mail's first parameter (recipient/to).
Comment 8 Mark A. Hershberger 2012-02-17 15:11:04 UTC
*** Bug 34464 has been marked as a duplicate of this bug. ***
Comment 9 Antoine "hashar" Musso (WMF) 2012-02-17 17:02:51 UTC
subject header dealt with r111765
Comment 10 Antoine "hashar" Musso (WMF) 2012-02-17 17:06:12 UTC
The To: header need a bit more investigation. Will attempt to poke at it tonight.
Comment 11 Alex Monk 2012-02-17 19:00:10 UTC
Created attachment 10032 [details]
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.
Comment 12 Sumana Harihareswara 2012-02-17 19:01:35 UTC
Thanks for the patch, Alex!  I added




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!
Comment 13 Alex Monk 2012-02-17 19:14:39 UTC
Created attachment 10034 [details]
Actual patch

So AttachURL didn't quite work how I was expecting. This should be the actual patch.
Comment 14 Sam Reed (reedy) 2012-02-17 19:28:12 UTC
*** Bug 34479 has been marked as a duplicate of this bug. ***
Comment 15 Alex Monk 2012-02-17 22:20:40 UTC
Created attachment 10036 [details]
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.
Comment 16 Antoine "hashar" Musso (WMF) 2012-02-18 15:37:48 UTC
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. 


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:'

Note You need to log in before you can comment on or make changes to this bug.