Page MenuHomePhabricator

Windows SMTP server not able to parse E-mail address format
Closed, ResolvedPublic


Author: superoni

Directly e-mailing a user will not perform properly while using Windows' builtin
SMTP server (Windows 2000 Server, Windows 2003 Server).

Normal notification e-mails work such as change notifications, password reminders.

However, if you try e-mailing directly a user, it fails possibly due to the way
it formats the e-mail address by combining the wiki user name like so:

Here is a sample of a SMTP log when this happens:

2006-02-13 19:44:59 W2K-US2 HELO - +W2K-US2 250 31 SMTP
2006-02-13 19:44:59 W2K-US2 MAIL - +FROM:<> 250 46
2006-02-13 19:44:59 W2K-US2 RCPT -
+TO:<David.forester+<>> 501 27 SMTP
2006-02-13 19:44:59 W2K-US2 QUIT - W2K-US2 240 56 SMTP

Version: 1.5.x
Severity: normal
OS: Windows XP
Platform: PC



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:05 PM
bzimport set Reference to bz4979.
bzimport added a subscriber: Unknown Object (MLST).

Comment: this is very dependent on the several windows versions.

tom.giesberg wrote:

Per, under Windows "the to parameter should
not be an address in the form of "Something <>"". As such, you can address
this by going to UserMailer.php and modify the MailAddress toString() function from:

if( $this->name != '') {
  return wfQuotedPrintable( $this->name ) . " <" . $this->address . ">";
} else {
  return $this->address;


if( $this->name != '' && $_ENV['OS']!='Windows_NT') {
[Everything else the same]

This will result in a simple email address that Windows' mail() implementation can handle.

mediawiki_bugzilla wrote:

(In reply to comment #2)
I would suggest adding the "Something <>"-style address to
the $headers variable and then modify the call to the mail()-function like so:

Start in line 118:

		$headers =
			"MIME-Version: 1.0\n" .
			"Content-type: text/plain; charset={$wgOutputEncoding}\n" .
			"Content-Transfer-Encoding: 8bit\n" .
			"X-Mailer: MediaWiki mailer\n".
			'From: ' . $from->toString() . "\n"/* CHANGE START */.
			"To: {$dest}\n"/* CHANGE END */;

And change line 134 to:

		mail( $to->address, wfQuotedPrintable( $subject ), $body, $headers );

This approach would be more portable.

Have you tested that? My recollection is that the broken function on Windows
reads the value from the From: header.

dgilman wrote:

I followed Comment #3 and my system was able to send emails to another Win2k3
SMTP box (our relay system).
I now have two new problems (must be my fat fingers):

  1. "Could not send confirmation mail. Check address for invalid characters." -

but the email goes forth!

  1. Any edit of a page results in "Sorry! We could not process your edit due to a

loss of session data. Please try again. If it still doesn't work, try logging
out and logging back in." Which doesn't go away when I logout, restart Apache,
etc. I have a 2nd wiki- it doesn't send email (yet) but it also gives this
second error.

I post this here as they both appeared as a result of fixing the above and wish
for others to properly execute your advice and not mess up as I have.

robchur wrote:

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

carl.duisberg wrote:

The bug is in UserMailer.php, function userMailer(). In version 1.7.1 there are
two lines setting $dest:

if (is_array( $wgSMTP )) {
(1) $dest = $to->address;
} else {
(2) $dest = $to->toString();

Line (1) is correct. Line (2) is wrong it causes the problem as is also
described in the code comment:
// Note: The to parameter cannot be an address in the form of "Something

Please change line (2) to
$dest = $to->address;

carl.duisberg wrote:

Patch for UserMailer.php

attachment patch.txt ignored as obsolete

carl.duisberg wrote:

Unified patch for UserMailer.php

attachment patch.txt ignored as obsolete

carl.duisberg wrote:

Patch vor UserMailer.php (revision 15871): $dest = $to->address;

Sorry for saving the same patch thrice. Had no SVN on my computer.


robchur wrote:

Should now be fixed in SVN trunk, r16285.

sselden wrote:

After using the fix in comment #7 I received this error, but email was sent
Error sending mail: mail() [function.mail]: It is not safe to rely on the
system's timezone settings. Please use the date.timezone setting, the TZ
environment variable or the date_default_timezone_set() function. In case you
used any of those methods and you are still getting this warning, you most
likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for
'-7.0/DST' instead

carl.duisberg wrote:

(In reply to comment #11)

Should now be fixed in SVN trunk, r16285.

Neither in 1.7.1
nor in snapshot work
the problem is fixed (r16418).

provoost wrote:

I'm not sure if this adds anything new to the discussion, but anyway...
I had the same problem with 'my' windows webserver in combination with
(probably) a windows smtp server. I am running version 1.6.8 (because of php4).
The log from the smtp server reads:

9/08/06 10:41:22 SMTP-OU 52C1ABFFDBE9423DA6A4E6F230F81E91.MAI 452 EHLO EHLO 34 96
09/08/06 10:41:22 SMTP-OU 52C1ABFFDBE9423DA6A4E6F230F81E91.MAI 452 MAIL MAIL FROM:<> SIZE=840 250 Ok 40
09/08/06 10:41:22 SMTP-OU 52C1ABFFDBE9423DA6A4E6F230F81E91.MAI 452 RCPT RCPT TO:<Zirrio <> 501 Bad
address syntax 38 24
09/08/06 10:41:22 SMTP-OU 52C1ABFFDBE9423DA6A4E6F230F81E91.MAI 452 QUIT QUIT 221 Bye 6 9
09/08/06 10:41:23 SMTP-OU B4DED6E0F5DC4D848A73A3448EA91E9B.MAI 452

Apparently, the problem is the address syntax:
<Zirrio <>
in stead of just describes a similar

I 'solved' it by changing includes/UserMailer.php around line 57


function toString() {

		if( $this->name != '' ) {
			return wfQuotedPrintable( $this->name ) . " <" . $this->address . ">";
		} else {
			return $this->address;



function toString() {

			return $this->address;


Can this problem also be fixed for 1.6.8 branch?

carl.duisberg wrote:

Fixed in mediawiki,
r16404, by not createing "Joe Bloggs <>" format email addresses in
windows at all (see MailAddress::toString()).