|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72964 White space not unfolded for CC/Bcc headers
Submitted: 2016-08-29 12:40 UTC Modified: -
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: hynek dot petrak at gmail dot com Assigned:
Status: Open Package: Mail related
PHP Version: 5.6.25 OS: Windows
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: hynek dot petrak at gmail dot com
New email:
PHP Version: OS:


 [2016-08-29 12:40 UTC] hynek dot petrak at gmail dot com
According to RFC2822 / 2.2.3. Long Header Fields, each header field can use White space folding. E.g.:

Subject: subject text

In the win32/sendmail.c SendText() function, the cc: and bcc: headers are considered only up to the next \r\n, ignoring any additional folded lines. This occures on Windows when "sendmail_path" is not defined in php.ini.

Problematic code:
                pos1 = headers + (pos1 - headers_lc) + 3;
                if (NULL == (pos2 = strstr(pos1, "\r\n"))) {
                        tempMailTo = estrndup(pos1, strlen(pos1));
                } else {
                        tempMailTo = estrndup(pos1, pos2 - pos1);
IMHO any folding sequence "\r\n\t" or "\r\n " shall be replaced with "\t" or " " in header_lc before scanning. Other solutions might be convenient too.

Test script:
$to      = '';
$subject = 'the subject';
$message = 'hello';
$headers = 'From:' . "\r\n" .
    'Cc:' . "\r\n" . ', ' .
    '\' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

Expected result:
---------------- shall receive an email.

Actual result:
-------------- does not receive an email. in the SMTP protocol RCPT TO: is missing.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Sep 27 17:01:24 2020 UTC