Doc #54012 [Com]: Line separators in additional_header parameter
| From: | ere at labs dot fi | Date: | Sat, 17 Dec 2011 22:14:05 +0000 |
| Subject: | Doc #54012 [Com]: Line separators in additional_header parameter | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7674@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54012&edit=1
ID: 54012
Comment by: ere at labs dot fi
Reported by: karl dot riedling at tuwien dot ac dot at
Summary: Line separators in additional_header parameter
Status: Open
Type: Documentation Problem
Package: Mail related
Operating System: Debian Lenny
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This is causing trouble with Hotmail.com too. It seems to me that the documentation error is based
on a misunderstanding. It is true that \r\n is used in the email, but it is the duty of the MTA to
construct the message properly. When PHP talks to the MTA, platform native line separators should be
used as that is communication between two tasks on the same platform, and the MTA (logically)
expects to receive input with proper line separators.
Previous Comments:
------------------------------------------------------------------------
[2011-02-14 14:05:40] karl dot riedling at tuwien dot ac dot at
Description:
------------
---
From manual page: http://www.php.net/function.mail#Parameters
---
Experienced in three different PHP installations under Debian Lenny (PHP/5.2.6-1+lenny9) and Red Hat
3.4.5-2 (PHP/5.0.4):
Using \r\n as line separators in the additional-header parameter, as required in the documentation
(_any_ version I found) causes severe problems with some mail clients. Apparently, either mail() or
the MTA adds an additional CR, which is no problem with most mail clients but effectively results in
extraneous linefeeds if the mail is received by GMX. These extraneous linefeeds preempt the mail
header section and move everything but the first header line into the mail body. Accordingly, the
MIME headers are not properly interpreted. This problem has been reported, incidentally, in several
forum postings, with hardly a good solution found there.
I replaced "\r\n" in my software with PHP_EOL; the pertinent section reads now:
$this->header = "From: ".$from;
if ($reply_to != "")
$this->header .= PHP_EOL."Reply-to: ".$reply_to;
$this->header .= PHP_EOL."X-Mailer: PHP/".phpversion();
$this->header .= PHP_EOL."MIME-Version: 1.0";
...
Test script:
---------------
Simply send a mail with "\r\n" in the additional_headers and with several lines in the
header section from a Linux environment to a gmx mail account. Replace "\r\n" with PHP_EOL
(which is "\n" under Linux), and note the difference.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54012&edit=1