Last modified: 2010-05-15 15:56:55 UTC
After upgrading to MediaWiki 1.6.1 I started having problems with SMTP not working when trying to send an email to an exchange server. This was not a problem when using MediaWiki 1.5.8. After doing some debugging I noticed that it is trying to send the email as User <user@domain.com> Exchange does not like this format so it can only be <user@domain.com> I am currently using The Following Items: PHP 5.1.2 (Win32) MySQL 5.0 (Win32)
I noticed in User.php you have the following code $to = new MailAddress( $this ); Shouldn't it be $to = new MailAddress( $this->getEmail() );
Your mail server doesn't like RFC compliant email addresses? Fix your mail server.
No, the user object is correct here. That allows it to include the user name. (Including the username is vital; otherwise there's no accountability as you can't tell which user on the wiki is mailing you.) It sounds like your mail server is severely broken; if that's a problem, something like 99% of mail perhaps wouldn't pass through your server...? :) We don't have any Win2k3, IIS, or Exchange to test with so you'll need to help. Can you provide some details, such as: * the error logs / messages * a playback of the SMTP session * exact headers of the message * details of mail configuration in LocalSettings.php * are you using PHP's mail() command (default) or PEAR::Mail configured with $wgSMTP?
I don't have access to our exchange server logs however this is the error message I get when telneting to port 25 and running the rfc commands. -- helo mail from: User <user@domain.com> 501 5.5.4 Invalid arguments -- if I do it via "mail from:<user@domain.com>" or "mail from: user@domain.com" then it works
Can you provide some details, such as: * details of mail configuration in LocalSettings.php * are you using PHP's mail() command (default) or PEAR::Mail configured with $wgSMTP?
* details of mail configuration in LocalSettings.php The only mail settings I have enabled are these $wgEnableEmail = true; $wgEnableUserEmail = true; $wgEmergencyContact = "lunatik@crazy.net"; $wgPasswordSender = "wikiadmin@crazy.net"; * are you using PHP's mail() command (default) or PEAR::Mail configured with $wgSMTP? And I am just using the PHP's default mail setup. ----- Also I was wrong on the last email. Exchange doesn't accept "mail from: user@domain.com" it appears that it just wants it as "mail from: <user@domain.com>" This has been tested both on an Exchange 2000 server and a Exchange 2003 server.
On a quick peek through win32/sendmail.c in PHP 5.1.2 source, it looks like it's incorrectly grabbing the entire contents of the message's 'From' header and dumping it into the SMTP return-path. That appears to be incorrect behavior. In fact it's a PHP bug that's been open for almost two years. :P http://bugs.php.net/bug.php?id=28038 As a workaround, try setting "sendmail_from" in php.ini or in your LocalSettings.php: ini_set("sendmail_from", "wiki-mailbox@myserver.example.com"); or try using the PEAR mail module. (See $wgSMTP comments in DefaultSettings.php)
I was looking around on the net and I came across this statement. Even though Exchange shows this error to be an "Invalid Address", this error (5.5.4) is actually a permanent error indicating invalid command arguments. See these RFCs: RFC1893 Enhanced Mail System Status Codes RFC2034 SMTP Service Extension for Returning Enhanced Error Codes This is the most probable cause: A trailing dot or a space after the fully qualified domain name (FQDN) is interpreted as incorrect syntax, and a 501 error message is generated. In accordance with RFC 821 and RFC 1869, Exchange 2000 and Exchange Server 5.5 SP4 do not allow trailing spaces and trailing dots. (Some SMTP hosts, such as SendMail servers, do allow trailing spaces and trailing dots.) This error can also appear like this: Connecting to ExchangeServerName Reading initial connect greeting R) 220 ExchangeServerName.Maildomain.COM Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Thu, 20 May 2005 09:14:07 -0500 Sending HELO command S) HELO WhatupServer.domain.com R) 250 ExchangeServerName.Maildomain.com Hello [192.168.1.100] Sending MAIL FROM: command S) MAIL FROM:"WhatsUp" <WhatsUp@Maildomain.com> R) 501 5.5.4 Invalid arguments SMTP Error (MAIL FROM Command) 501 5.5.4 Invalid arguments In this case you will want to use <WhatsUp@Maildomain.com> as the MAIL FROM address, rather than the compound email address: "WhatsUp" <WhatsUp@Maildomain.com>
From My Comments Earlier in this bug I noticed something in one of the files which when I changed it it worked fine. Original Message Below. ---- I noticed in User.php you have the following code $to = new MailAddress( $this ); Shouldn't it be $to = new MailAddress( $this->getEmail() ); ---- When I make this change in User.php it works just fine.
Resolving INVALID as this is a PHP bug and there are several workarounds to use until it's fixed in PHP (see above).
*** Bug 5671 has been marked as a duplicate of this bug. ***