Last modified: 2010-05-15 15:37:39 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T6979, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 4979 - Windows SMTP server not able to parse E-mail address format
Windows SMTP server not able to parse E-mail address format
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.5.x
PC Windows XP
: Normal normal with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
: 6659 (view as bug list)
Depends on:
Blocks: 7438
  Show dependency treegraph
 
Reported: 2006-02-13 20:01 UTC by Superoni
Modified: 2010-05-15 15:37 UTC (History)
1 user (show)

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


Attachments
Patch for UserMailer.php (69 bytes, patch)
2006-07-28 20:21 UTC, Carl Duisberg
Details
Unified patch for UserMailer.php (308 bytes, patch)
2006-07-28 20:32 UTC, Carl Duisberg
Details
Patch vor UserMailer.php (revision 15871): $dest = $to->address; (355 bytes, patch)
2006-07-28 21:27 UTC, Carl Duisberg
Details

Description Superoni 2006-02-13 20:01:45 UTC
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 127.0.0.1 W2K-US2 HELO - +W2K-US2 250 31 SMTP
2006-02-13 19:44:59 127.0.0.1 W2K-US2 MAIL - +FROM:<wikiadmin@XXXXXX.com> 250 46
SMTP
2006-02-13 19:44:59 127.0.0.1 W2K-US2 RCPT -
+TO:<David.forester+<david.forester@XXXXXX.com>> 501 27 SMTP
2006-02-13 19:44:59 127.0.0.1 W2K-US2 QUIT - W2K-US2 240 56 SMTP
Comment 1 T. Gries 2006-02-13 23:25:47 UTC
Comment: this is very dependent on the several windows versions.
Comment 2 Tom Giesberg 2006-05-02 17:16:50 UTC
Per http://us2.php.net/manual/en/function.mail.php, under Windows "the to parameter should 
not be an address in the form of "Something <someone@example.com>"". 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;
  }

to:

  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.
Comment 3 Christian Blichmann 2006-05-17 12:33:15 UTC
(In reply to comment #2)
I would suggest adding the "Something <someone@example.com>"-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.
Comment 4 Brion Vibber 2006-05-17 18:09:29 UTC
Have you tested that? My recollection is that the broken function on Windows
reads the value from the From: header.
Comment 5 Don R Gilman 2006-07-06 20:27:17 UTC
I followed Comment #3 and my system was able to send emails to another Win2k3
SMTP box (our relay system).
HOWEVER:
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!
2. 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.
Comment 6 Rob Church 2006-07-13 09:51:16 UTC
*** Bug 6659 has been marked as a duplicate of this bug. ***
Comment 7 Carl Duisberg 2006-07-28 19:57:31 UTC
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
<someone@example.com>".

Please change line (2) to 
$dest = $to->address;
Comment 8 Carl Duisberg 2006-07-28 20:21:37 UTC
Created attachment 2164 [details]
Patch for UserMailer.php
Comment 9 Carl Duisberg 2006-07-28 20:32:14 UTC
Created attachment 2165 [details]
Unified patch for UserMailer.php
Comment 10 Carl Duisberg 2006-07-28 21:27:19 UTC
Created attachment 2166 [details]
Patch vor UserMailer.php (revision 15871): $dest = $to->address;

Sorry for saving the same patch thrice. Had no SVN on my computer.
Comment 11 Rob Church 2006-08-30 13:56:12 UTC
Should now be fixed in SVN trunk, r16285.
Comment 12 sharon selden 2006-09-04 05:29:17 UTC
After using the fix in comment #7 I received this error, but email was sent
sucessfully.
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
Comment 13 Carl Duisberg 2006-09-05 18:13:26 UTC
(In reply to comment #11)
> Should now be fixed in SVN trunk, r16285.

Neither in 1.7.1
(http://svn.wikimedia.org/svnroot/mediawiki/branches/REL1_7/phase3/includes/UserMailer.php)
nor in snapshot work
(http://svn.wikimedia.org/svnroot/mediawiki/branches/snapshot-work/includes/UserMailer.php)
the problem is fixed (r16418).
Comment 14 Sjors Provoost 2006-09-10 15:19:44 UTC
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
193.93.174.20	EHLO	EHLO WSLEASENOBOR01.noborders.nl
250-wsspam02.livemail.nl	34	96	
09/08/06 10:41:22	SMTP-OU	52C1ABFFDBE9423DA6A4E6F230F81E91.MAI	452
193.93.174.20	MAIL	MAIL FROM:<info@noborders.nl> SIZE=840	250 Ok	40
8	
09/08/06 10:41:22	SMTP-OU	52C1ABFFDBE9423DA6A4E6F230F81E91.MAI	452
193.93.174.20	RCPT	RCPT TO:<Zirrio <sirio@noborders.nl>	501 Bad
address syntax	38	24	
09/08/06 10:41:22	SMTP-OU	52C1ABFFDBE9423DA6A4E6F230F81E91.MAI	452
193.93.174.20	QUIT	QUIT	221 Bye	6	9	
09/08/06 10:41:23	SMTP-OU	B4DED6E0F5DC4D848A73A3448EA91E9B.MAI	452
193.93.174.20

Apparently, the problem is the address syntax:
<Zirrio <sirio@noborders.nl>
in stead of just 
sirio@noborders.nl

http://archives.neohapsis.com/archives/php/2004-08/0007.html describes a similar
problem.

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

Replace:
---
	function toString() {
		if( $this->name != '' ) {
			return wfQuotedPrintable( $this->name ) . " <" . $this->address . ">";
		} else {
			return $this->address;
		}
	}
---
by:
---
	function toString() {
			return $this->address;
	}
---
Can this problem also be fixed for 1.6.8 branch?
Comment 15 Carl Duisberg 2006-09-16 14:42:02 UTC
Fixed in mediawiki
http://svn.wikimedia.org/svnroot/mediawiki/branches/snapshot-work/includes/UserMailer.php,
r16404, by not createing "Joe Bloggs <joe@bloggs.com>" format email addresses in
windows at all (see MailAddress::toString()).

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


Navigation
Links