From:             junkmail-trash at cowsgo dot mu
Operating system: Windows XP / Apache 
PHP version:      5.1.2
PHP Bug Type:     Mail related
Bug description:  From: Header not being parsed correctly in generation of 
Return-Path header

Description:
------------
When using PHP's mail function on Windows, the Return-Path: header is
generated by PHP automatically.  The value for the header is derived from
the From: header supplied by the user.

The problem is that if there is a name in the From: header, such as:

From: "Joe Bob" <[EMAIL PROTECTED]>

PHP will mangle the Return-Path: header as:

Return-Path: <"Joe Bob <joe"@bob.com>

Some MTAs will then reject the entire email for having an invalid
Return-Path header.

To observe this, you need to sniff the SMTP connection using a tool like
tcpflow, or view the message source if it is delivered correctly.  The
From: header displayed by your mail client is not an indicator of the
Return-Path: header.

Please reference http://cr.yp.to/immhf/envelope.html for a nice
human-readable interpetation of the relevant RFCs.

Reproduce code:
---------------
ini_set('SMTP', 'youremailserver.com');
ini_set('smtp_port', '25');

$header = "From: \"Some Guy\" <[EMAIL PROTECTED]>\r\n";
mail("[EMAIL PROTECTED]","Test Subject", "Test Message", $header);

Expected result:
----------------
(Using Thunderbird's "View Source" option)

>From - Thu Apr 13 11:26:12 2006
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: <[EMAIL PROTECTED]>
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 29537 invoked from network); 13 Apr 2006 18:26:14 -0000
Received: from localhost (HELO foo) (127.0.0.1)
  by somesite.com with SMTP; 13 Apr 2006 18:26:14 -0000
Date: Thu, 13 Apr 2006 11:26:04 -0700
Subject: Test Subject
To: [EMAIL PROTECTED]
From: "Joe Bob" <[EMAIL PROTECTED]>

Test Message

Actual result:
--------------
(Using Thunderbird's "View Source" option)

>From - Thu Apr 13 11:26:12 2006
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: <"Joe Bob <joe"@bob.com>
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 29537 invoked from network); 13 Apr 2006 18:26:14 -0000
Received: from localhost (HELO foo) (127.0.0.1)
  by somesite.com with SMTP; 13 Apr 2006 18:26:14 -0000
Date: Thu, 13 Apr 2006 11:26:04 -0700
Subject: Test Subject
To: [EMAIL PROTECTED]
From: "Joe Bob" <[EMAIL PROTECTED]>

Test Message

-- 
Edit bug report at http://bugs.php.net/?id=37073&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37073&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=37073&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37073&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37073&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37073&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37073&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37073&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37073&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37073&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37073&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37073&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37073&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37073&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37073&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37073&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37073&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37073&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37073&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37073&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37073&r=mysqlcfg

Reply via email to