Bug #51810 [NEW]: empty line added if $header is given to mail()

From: Date: Thu, 13 May 2010 14:58:14 +0000
Subject: Bug #51810 [NEW]: empty line added if $header is given to mail()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150434@lists.php.net to get a copy of this message
From:             
Operating system: Linux / SuSE 11.2 and 10.2
PHP version:      5.3.2
Package:          Mail related
Bug Type:         Bug
Bug description:empty line added if $header is given to mail()

Description:
------------
If mail() is called with the $header argument, an empty line is inserted
before the $header ĺine. Therefore the content of $header is not seen as
valid mail header.



Test script:
---------------
<?php

$crlf = chr(13) . chr(10);

$to      = "me@example.com";
$subject = "my subject";
$body1   = "my body -- with header";
$body2   = "my body -- no header";
$header  = "From: you@example.com${crlf}".
           "X-Mailer: PHP/" . phpversion() . $crlf;

$res1 = mail ($to, $subject, $body1, $header);
$res2 = mail ($to, $subject, $body2);

printf ("mail res=${res1}; ${res2}\n");
?>

Actual result:
--------------
If $header is given (see example above) the (shortened) mail text looks
like:
---------------------------  from here
Return-Path: <....>
Received: ....
To: me@example.com
Subject: my sub
X-Mailer: PHP/5.3.1
Message-Id: <...>
From: ...
Message-Id: <...>
Date: ...
X-Length: 2014
X-UID: 252148

Message-Id: <...>
Date: ....
From: ....


my body -- with header1
---------------------- to here

Now After X-UID: there is an empty line, which should n ot be there (in my
opinion).


-- 
Edit bug report at http://bugs.php.net/bug.php?id=51810&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51810&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51810&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51810&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51810&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51810&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51810&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51810&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51810&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51810&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51810&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51810&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51810&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51810&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51810&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51810&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51810&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51810&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51810&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51810&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51810&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51810&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#150434) next »