#28038 [Com]: Sent incorrect RCPT TO commands to SMTP server
| From: | papercrane at reversefold dot com | Date: | Thu, 05 Aug 2004 23:59:47 +0000 |
| Subject: | #28038 [Com]: Sent incorrect RCPT TO commands to SMTP server | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-64171@lists.php.net to get a copy of this message | ||
ID: 28038
Comment by: papercrane at reversefold dot com
Reported By: jordi at jcanals dot net
Status: Assigned
Bug Type: Mail related
Operating System: Windows
PHP Version: 4.3.6
Assigned To: wez
New Comment:
Here's a possible patch for it. It's pretty simplistic, bit it should
work:
http://www.reversefold.com/sendmail.c.patch
Full file:
http://www.reversefold.com/sendmail.c
NOTE: I haven't actually *tested* this, it may not even compile. If it
doesn't, please send me a note and I'll try to fix it.
Previous Comments:
------------------------------------------------------------------------
[2004-04-28 00:11:33] jordi at jcanals dot net
Just to complement the coments: If you write an explicit Return-Path:
header, this header is not considered by the mail function. The
function changes this header to the one set on the sendmail_from
address in php.ini.
I thing this is just a behavior by desing, but could be an improvement
if it use the Return-Path header in the future. Could not be tested on
Linux.
Sample:
=======
PHP.INI
-------
sendmail_from=php_ini@example.org
Code
----
$header = "Return-Path: return@example.org\r\n";
$header .= "From: sender@example.org\r\n";
mail('recipient@example.org', 'subject', 'bla bla', $header);
The sent headers are:
From: sender@example.org
To: recipient@example.org
Return-Path: php_ini@example.org
------------------------------------------------------------------------
[2004-04-19 19:09:40] derick@php.net
If you think it's a bug you may fix it :)
------------------------------------------------------------------------
[2004-04-19 15:17:15] wez@php.net
It is a bug, since PHP is sending those headers by parsing the email.
------------------------------------------------------------------------
[2004-04-18 01:00:13] derick@php.net
Mailing with PHP on Windows doesn't support this. Not a bug.
------------------------------------------------------------------------
[2004-04-17 19:14:01] jordi at jcanals dot net
Description:
------------
In windows, and using an SMTP server, when you try to send a mail using
the mail function the SMTP transaction will fail if you include
recipient names.
When including any recipient header in the following format (wich
follows the RFC 2822), the mail function does not handle it properly:
To: User Name <address@example.com>
Cc: Other User <other@example.net>
Bcc: Third User <third@example.org>
Loking at the SMTP transaction, the PHP mail layer sends this RCPT
commands wich do not folow the SMTP standard stated on RFC 2821:
RCPT TO:<User Name <address@example.com>>
RCPT TO:<Other User <other@example.net>>
RCPT TO:<Third User <third@example.org>>
Fails always with this environments:
Tested on Windows XP, Apache 2.0.49, PHP 4.3.6 (Also in 4.3.4)
Tested also on Windows 2000, IIS, PHP 4.3.6
Tested Using SMTP servers on Linux with Exim and Sendmail.
Tested also using the default Windows 2000 SMTP server.
Reproduce code:
---------------
// SAMPLE 1:
$to_recipient = "User Name <address@example.com>";
$header = "Cc: Other User <other@example.net>\r\n";
$header .= "Bcc: Third User <third@example.org>\r\n";
mail($to_recipient, $subject, $body, $header);
// FAILS with SMTP errors for all three recipients.
SAMPLE 2:
$to_recipient = "address@example.com";
$header = "To: User Name <recipient@example.com>\r\n";
$header .= "Cc: Other User <other@example.net>\r\n";
$header .= "Bcc: Third User <third@example.org>\r\n";
mail($to_recipient, $subject, $body, $header);
FAILS on with SMTP error on the three recipients passed on the $header
field.
Expected result:
----------------
Expected that the mail layer exctracts only the mail address from
recipients to send the SMTP commands:
As seen on the RFC's 2821 and 2822, when sending a mail with the
recipient headers formed like above, it is expected the mail layer to
extract ONLY the email address to send the RCPT commands, and pass the
headers without any change in the DATA command during the SMTP
transaction. Example of the correct SMTP transaction for the above
headers:
RCPT TO:<address@example.com>
RCPT TO:<other@example.net>
RCPT TO:<third@example.org>
DATA
To: User Name <address@example.com>
Cc: Other User <other@example.net>
Bcc: Third User <third@example.org>
Actual result:
--------------
You get that error for all recipients with the recipient name:
Warning: mail(): SMTP server response: 501 <SomeOne Name
<someone@example.com>>: "@" or "." expected after "SomeOne"
in
mail.class.php on line 333
This error is produced when the mail layer is sending a wrong formed
RCPT TO: command in the SMTP transaction.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28038&edit=1