From:             jordi at jcanals dot net
Operating system: Windows
PHP version:      4.3.6
PHP Bug Type:     Mail related
Bug description:  Sent incorrect RCPT TO commands to SMTP server

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 <[EMAIL PROTECTED]>
Cc: Other User <[EMAIL PROTECTED]>
Bcc: Third User <[EMAIL PROTECTED]>

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 <[EMAIL PROTECTED]>>
RCPT TO:<Other User <[EMAIL PROTECTED]>>
RCPT TO:<Third User <[EMAIL PROTECTED]>>

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 <[EMAIL PROTECTED]>";
$header = "Cc: Other User <[EMAIL PROTECTED]>\r\n";
$header .= "Bcc: Third User <[EMAIL PROTECTED]>\r\n";
mail($to_recipient, $subject, $body, $header);

// FAILS with SMTP errors for all three recipients.

SAMPLE 2:
$to_recipient = "[EMAIL PROTECTED]";
$header = "To: User Name <[EMAIL PROTECTED]>\r\n";
$header .= "Cc: Other User <[EMAIL PROTECTED]>\r\n";
$header .= "Bcc: Third User <[EMAIL PROTECTED]>\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:<[EMAIL PROTECTED]>
RCPT TO:<[EMAIL PROTECTED]>
RCPT TO:<[EMAIL PROTECTED]>

DATA

To: User Name <[EMAIL PROTECTED]>
Cc: Other User <[EMAIL PROTECTED]>
Bcc: Third User <[EMAIL PROTECTED]>


Actual result:
--------------
You get that error for all recipients with the recipient name:

Warning: mail(): SMTP server response: 501 <SomeOne Name
<[EMAIL PROTECTED]>>: "@" 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 bug report at http://bugs.php.net/?id=28038&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28038&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28038&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28038&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28038&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28038&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28038&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28038&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28038&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28038&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28038&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28038&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28038&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28038&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28038&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28038&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28038&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28038&r=float

Reply via email to