php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73507 Extra space added before additional headers when mail.add_x_header is enabled
Submitted: 2016-11-12 18:10 UTC Modified: 2016-11-24 20:53 UTC
From: mattcoz at yahoo dot com Assigned:
Status: Not a bug Package: *Mail Related
PHP Version: 7.0.13 OS: Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mattcoz at yahoo dot com
New email:
PHP Version: OS:

 

 [2016-11-12 18:10 UTC] mattcoz at yahoo dot com
Description:
------------
When the server is set up with the mail.add_x_header preference enabled, an extra space is added before the additional headers. In my example where I set the From address in my additional headers, this causes it to add an additional From header. The email is then blocked if sent to gmail addresses. This does not happen on another server running PHP 5.3.13 with the same settings.

I've attempted to look at the mail.c code and find the problem, but I don't see anywhere that might explain why the extra space is being added.

Test script:
---------------
mail("to@email.com", "Subject", "Message", "From: from@email.com");

Expected result:
----------------
To: <to@email.com>
X-PHP-Originating-Script: 0:test.php
From: <from@email.com>

Actual result:
--------------
To: <to@email.com>
X-PHP-Originating-Script: 0:test.php
 From: from@email.com
From: <from@email.com>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-13 15:06 UTC] cmb@php.net
I can't reproduce the reported behavior (neither on Windows with
php-7.0.13-nts-Win32-VC14-x86, nor on Linux with current PHP-5.6
and PHP-7.0):

php -n -d mail.add_x_header=1 -d sendmail_path="cat -" -r "mail('to@email.com', 'Subject', 'Message', 'From: from@email.com');"
To: to@email.com
Subject: Subject
X-PHP-Originating-Script: 1:Command line code
From: from@email.com

Message
 [2016-11-21 11:24 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-11-21 11:24 UTC] ab@php.net
I don't reproduce this as well, debugged also through the Windows only sendmail part. @mattcoz at yahoo dot com, there must be something in the configuration, or the data, so we can reproduce this as well.

Thanks.
 [2016-11-21 16:52 UTC] mattcoz at yahoo dot com
-Status: Feedback +Status: Open
 [2016-11-21 16:52 UTC] mattcoz at yahoo dot com
Ok, so I tried this on another server with a fresh copy of PHP 7.0.13. I created a php.ini file with the only settings being my smtp server and mail.add_x_header = On. I then tested my script and got the same problem.
 [2016-11-21 18:50 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-11-21 18:50 UTC] ab@php.net
@mattcoz at yahoo dot com, please describe in detail the way you trigger the bug.

Thanks.
 [2016-11-24 05:50 UTC] mattcoz at yahoo dot com
What additional detail are you looking for?
 [2016-11-24 17:15 UTC] mattcoz at yahoo dot com
Ok, I tested this with a different SMTP server and the problem goes away. I'm not sure why this would have been working in PHP5 though.
 [2016-11-24 20:53 UTC] yohgaki@php.net
-Status: Feedback +Status: Not a bug
 [2016-11-24 20:53 UTC] yohgaki@php.net
Some MTA/UMA treat LF, CR as CR/LF, convert LF, CR to CR/LF, but others not.
These things can happen.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 16:01:26 2024 UTC