|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
21 + 29 = ?
Subscribe to this entry?

 [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