Re: Problems with mail on Windows

From: Date: Sun, 18 Apr 2004 00:19:16 +0000
Subject: Re: Problems with mail on Windows
References: 1 2 3 4  Groups: php.windows 
Request: Send a blank email to php-windows+get-23481@lists.php.net to get a copy of this message
Jordi Canals wrote:
The main problem is when sending mail from Windows with the mail() function and using and SMTP server. The mail function modifies the TO header (CC and BCC also). The change made by the mail function does not conform with the RFC 2822 (wich obsoletes 822), and then the SMTP server does not accept the mail because headers are incorrectly formed. Here the examples: (Note that all examples work perfect on Linux, only fails on windows)
mail("someone@example.com", $subject, $text);        // WORKS
mail("My Name <someone@example.net>", $sub, $txt);    // FAILS
Also, the function fails when you write additional headers with the Cc: and Bcc: Fiels in the same format: $header = "Cc: Someone Name <someone@example.org\r\n"; $header .= "Bcc: Someother Name <anybody@example.com\r\n";
mail("someone@example.net", $sub, $txt, $header);    // FAILS
All this headers follow the RFC 2822, and the SMPT server would accept them with no problems. (And it really does). The problem is that the PHP mail layer on windows changes this headers encolsing them betwen the signs <>. Looking at the SMTP dialog, you can see that the mail() function encloses all adresses betwen <>, and then the address are: To: <someone@example.com> To: <My Name <someone@example.net>> Cc: <Someone Name <someone@example.org>> Bcc: <Someothe Name <anybody@example.com>> What's the problem? Main problem is when the function starts sending mail, because it modifies the additional headers. Modifiying the To:, Cc: and Bcc: fields ... and then using the modified addresses in the RCPT TO comand to send the mail. The SMTP standard, stated on RFC 2821, expects only the email address on the RCPT TO: command. This command MUST be formed this way: RCPT TO:<someone@example.com> But PHP sends all the To: field in the form: RCPT TO:<Someone Name <someone@example.com>> wich does not conform the standard. Then, the same SMTP standard, expects all headers (Without any modification) to be sent in the DATA section: DATA From: Jordi Canals <llistes@mydomain.net> To: Someone Name <someone@example.com> ... so, in my opinion, the mail layer should extract the e-mail adrresses to send the RCPT commands, and leave the headers with no changes to send them in the SMTP DATA section.
Ok, I've submited a bug and the answer was: Sending recipient headers with this format is NOT suported on Windows. So, in windows, you can use only email addresses on the recipient headers. Sending mail with repicients in the form stated above is only implemented on Linux and Unix Platforms. More info about this at: http://bugs.php.net/bug.php?id=28038 Thanks to all for your time. Regards, Jordi.

« previous php.windows (#23481) next »