From: shahar dot e at zend dot com
Operating system: Mac OS X 10.5
PHP version: 5.3.0RC4
PHP Bug Type: Mail related
Bug description: X-PHP-Originating-Script assumes no trailing CRLF in $headers
Description:
------------
It is very possible for a developer to use code like in the attached
reproduction code to send an e-mail. However, when mail.add_x_header is On,
using this code will cause the X-PHP-Originating-Script to show in the
message body instead of as a header.
This is because mail() assumes the $headers parameter is a string which
does not end with a trailing CRLF - while in practice it very well may be
(it works well when mail.add_x_header is Off).
Reproduce code:
---------------
<?php
$headers = array(
'X-Foo' => 'bar',
'From' => '[email protected]',
'Priority' => 'Urgent'
);
$hdrStr = '';
foreach($headers as $k => $v) {
$hdrStr .= "$k: $v\r\n";
}
mail('[email protected]',
'Testing add_x_header',
'This is a test',
$hdrStr);
Expected result:
----------------
Mail to look like:
To: [email protected]
Subject: Testing add_x_header
X-Foo: bar
From: [email protected]
Priority: Urgent
Date: Sat, 20 Jun 2009 20:37:34 +0300 (IDT)
X-PHP-Originating-Script: 503:mailtest.php
This is a test
Actual result:
--------------
To: [email protected]
Subject: Testing add_x_header
X-Foo: bar
From: [email protected]
Priority: Urgent
Date: Sat, 20 Jun 2009 20:37:34 +0300 (IDT)
X-PHP-Originating-Script: 503:mailtest.php
This is a test
* this is how I receive the e-mail in GMail - perhaps there is some header
mangling but you get the point
--
Edit bug report at http://bugs.php.net/?id=48620&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48620&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48620&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48620&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48620&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48620&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48620&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48620&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48620&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48620&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48620&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48620&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48620&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48620&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48620&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48620&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48620&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48620&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48620&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48620&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48620&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48620&r=mysqlcfg