|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72086 Regression handling Bcc and Cc headers
Submitted: 2016-04-23 12:01 UTC Modified: 2021-10-24 04:22 UTC
Avg. Score:3.3 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bill dot seddon at lyquidity dot com Assigned: cmb (profile)
Status: No Feedback Package: Mail related
PHP Version: 7.0.5 OS: Windows x86 NTS
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-04-23 12:01 UTC] bill dot seddon at lyquidity dot com
The mail function in 7.0.x does not work if the headers parameter contains an unnamed Bcc or Cc address or if it is not the last header.  In the error cases the function will return a 550 status code however the function does not contact the SMTP server at this time.

The function will re  The function will successfully send an email that includes this header:

Bcc: Me <>

But will fail and return false if the header is:


Both work when used with version 5.3 (I have not checked later versions).

The unnamed address ( will work if the Bcc header is the last header or if the From header is the last header and Bcc is the penultimate header.  There are other weird combinations that work/do not work.  In the test script I've provided an illustration.

Clearly the success or failure of the function should not depend upon the relative position of a header on the set of headers.

Test script:
This a basic function call.  Alternative headers are provided after.

echo mail( "", "Subject", "Some message", implode( "\n", $headers ), "" ) ? "Sent" : "Not sent";

// This header works because the Bcc is at the end
$headers = array(
	"Date: Sat, 23 Apr 2016 11:25:00 +0000",
	"From: Some sender <>",

// This header fails because the Bcc is not at the end
$headers = array(
	"From: Some sender <>",
	"Date: Sat, 23 Apr 2016 11:25:00 +0000",

// This header works because the Bcc is the penultimate
$headers = array(
	"Date: Sat, 23 Apr 2016 11:25:00 +0000",
	"From: Some sender <>",

Expected result:
The mail to be sent providing the email addresses themselves are valid.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-17 17:27 UTC] jpmoularde at free dot fr
Same issue with PHP Version 5.5.9-1ubuntu4.14 

Additional information:
$headers = array('From: Some user<>',
                 'Content-type: text/plain; charset=iso-8859-1;',
		 'Content-Transfer-Encoding: 8bit;',
                 'Bcc: <>');
works well whereas
1) $headers = array('From: Some user<>',
                    'Bcc: <>',
                    'Content-type: text/plain; charset=iso-8859-1;',
		    'Content-Transfer-Encoding: 8bit;',
                    'Bcc: <>');
results in the 'Content-type:' parameter being deeply flawed in the resulting message
2) 'Cc: Some user<>' or 'Bcc: Some user<>'
result in the mail() function returning "false", i.e. the only valid syntax is 
'Cc:' or 'Bcc:'

These issues are regressions vis a vis le previous version I used for years (PHP 5.2.xx)
 [2021-10-11 17:09 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-10-11 17:09 UTC]
It looks like this has been fixed in the meantime, or do you still
experience this with any of the actively supported PHP

[1] <>
 [2021-10-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 22:01:28 2024 UTC