php.net |  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
Votes:3
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
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
31 + 46 = ?
Subscribe to this entry?

 
 [2016-04-23 12:01 UTC] bill dot seddon at lyquidity dot com
Description:
------------
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 <me@mydomain.com>

But will fail and return false if the header is:

Bcc: me@mydomain.com

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

The unnamed address (me@domain.com) 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( "recipient@mydomain.com", "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",
	"To: recipient@mydomain.com",
	"From: Some sender <info@mydomain.com>",
	"Bcc: me@lyquidity.com",
);

// This header fails because the Bcc is not at the end
$headers = array(
	"To: recipient@mydomain.com",
	"From: Some sender <info@mydomain.com>",
	"Bcc: me@lyquidity.com",
	"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",
	"To: recipient@mydomain.com",
	"Bcc: me@mydomain.com",
	"From: Some sender <info@mydomain.com>",
);


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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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

[1] <https://www.php.net/supported-versions.php>
 [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-2021 The PHP Group
All rights reserved.
Last updated: Sat Nov 27 18:03:14 2021 UTC