|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54298 Using empty additional_headers adding extraneous CRLF
Submitted: 2011-03-17 18:28 UTC Modified: 2020-01-06 13:53 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: anrdaemon at freemail dot ru Assigned: cmb (profile)
Status: Closed Package: Mail related
PHP Version: Irrelevant OS: Win32/*NIX32
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.
Bug Type:
From: anrdaemon at freemail dot ru
New email:
PHP Version: OS:


 [2011-03-17 18:28 UTC] anrdaemon at freemail dot ru
Using the code sample below, you could see that it adds a "\r\n" to the end of the mail headers irrelevant to $additional_headers containing a meaningful value.
Even using an
empty($addParams) ? NULL/false : implode()
replacement, it does not fix the problem. The resulting message will still start from second line. Which is bad for look.
To beat it, you're forced to check for empty($addParams) before invoking mail() (and to have two separate mail() lines in your code, which does not lead to the code clarity)...

Test script:

$addParams = array();
mail('', 'testsubj', 'Body part', implode("\r\n", $addParams));


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-05 14:19 UTC]
-Status: Open +Status: Verified
 [2020-01-05 14:19 UTC]
As of PHP 7.2.0, there's no need anymore to implode() the array,
since $additional_headers accepts an array in the first place.
Doing so won't add the extraneous line break, so this issue is
partially resolved.  Still, when passing an empty string, there
should be no extraneous line break.
 [2020-01-05 14:19 UTC]
The following pull request has been associated:

Patch Name: Fix #54298: Using empty additional_headers adding extraneous CRLF
On GitHub:
 [2020-01-06 13:51 UTC]
Automatic comment on behalf of
Log: Fix #54298: Using empty additional_headers adding extraneous CRLF
 [2020-01-06 13:51 UTC]
-Status: Verified +Status: Closed
 [2020-01-06 13:53 UTC]
-Assigned To: +Assigned To: cmb
 [2020-01-07 13:16 UTC] anrdaemon at yandex dot ru
Submitted:	2011-03-17 18:28 UTC

[2020-01-06 13:51 UTC] 
-Status: Verified
+Status: Closed

Many thanks for this Christmas gift.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 20:01:29 2024 UTC