php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54012 Line separators in additional_header parameter
Submitted: 2011-02-14 14:05 UTC Modified: 2012-11-12 03:58 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: karl dot riedling at tuwien dot ac dot at Assigned:
Status: Duplicate Package: Mail related
PHP Version: Irrelevant OS: Debian Lenny
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: karl dot riedling at tuwien dot ac dot at
New email:
PHP Version: OS:

 

 [2011-02-14 14:05 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-17 22:14 UTC] ere at labs dot fi
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.
 [2011-12-17 22:18 UTC] ere at labs dot fi
Happens also with Ubuntu + Postfix.
 [2012-11-12 03:58 UTC] aharvey@php.net
Ended up dealing with this in doc bug #63416.
 [2012-11-12 03:58 UTC] aharvey@php.net
-Status: Open +Status: Duplicate
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Nov 27 12:05:54 2022 UTC