php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49355 Unable to properly fold To/Subject in emails
Submitted: 2009-08-25 09:47 UTC Modified: 2009-09-16 12:32 UTC
Votes:13
Avg. Score:4.7 ± 0.6
Reproduced:10 of 10 (100.0%)
Same Version:4 (40.0%)
Same OS:5 (50.0%)
From: php dot net at chris dot cs278 dot org Assigned:
Status: Open Package: Mail related
PHP Version: 5.2.10 OS: win32 only
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php dot net at chris dot cs278 dot org
New email:
PHP Version: OS:

 

 [2009-08-25 09:47 UTC] php dot net at chris dot cs278 dot org
Description:
------------
The SKIP_LONG_HEADER_SEP macro only permits CR-LF-WSP as a separator which works fine for SMTP, but sendmail under NIX requires LF as the new line character. The macro doesn't skip over LF-WSP which causes the LF to be replaced with a space, unfolding the header. This makes it near impossible to use UTF-8/etc. encoded strings for these headers.

I posted to internals about this problem: http://marc.info/?l=php-internals&m=125110373328523&w=2

Reproduce code:
---------------
mail('tester@example.net', "Reproduction test e-mail for PHP bug breaking the correct wrapping\n of e-mails with long To/Subject headers.", 'Testing...');

Expected result:
----------------
To: tester@example.net
Subject: Reproduction test e-mail for PHP bug breaking the correct wrapping  of e-mails with long To/Subject headers.

Testing...

Actual result:
--------------
To: tester@example.net
Subject: Reproduction test e-mail for PHP bug breaking the correct wrapping
 of e-mails with long To/Subject headers.

Testing...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-19 18:04 UTC] lukas dot starecek at centrum dot cz
We have same problem on *nix system with PHP 5.1.6 and PHP 5.3.2. In mail function is allowed to use only \r\n to separate chunks of subject, but email with this subject is damaged when processed by microsoft SMTP server (I think some kind of exchange server). In damaged email are chunks of subjects followed by two new lines, which means end of header. Below you can see broken email headers. The part after "MIME-Version: 1.0" is supposed to be message body, but you can se fragments of second and following lines of chunked subject, and email headers, which was after subject in original email.

----------

Received: from ***** (*****) by *****
 (*****) with Microsoft SMTP Server (TLS) id 8.1.393.1; Wed, 19 May
 2010 15:03:47 +0200
Received: from ***** (*****) by
 ***** (*****) with Microsoft SMTP Server id
 8.2.176.0; Wed, 19 May 2010 15:03:45 +0200
Received: by ***** (Postfix, from userid 48)id 72D6A36C2D; Wed,
	 19 May 2010 15:03:53 +0200 (CEST)
From: infooma <*****>
To: *****
Date: Wed, 19 May 2010 15:03:45 +0200
Subject: 
 =?Windows-1252?Q?Spam=5Fcsc:_POZOR!!_JEDN=C1_SE_O_TESTOVAC=CD_NOTIFIKACI_?=
 =?Windows-1252?Q?=8EoP_?=
Thread-Topic: 
 =?Windows-1252?Q?Spam=5Fcsc:_POZOR!!_JEDN=C1_SE_O_TESTOVAC=CD_NOTIFIKACI_?=
 =?Windows-1252?Q?=8EoP_?=
Thread-Index: Acr3U7hpsAXS9QjASjS/sZtv0YXFjg==
Message-ID: <3167228c-f54a-4a6b-b6c7-c7c1e5dc6990@*****>
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: *****
X-MS-Has-Attach: 
X-MS-Exchange-Organization-SenderIdResult: None
X-MS-Exchange-Organization-PCL: 2
X-MS-Exchange-Organization-PRD: *****
X-MS-TNEF-Correlator: 
received-spf: None (*****: ***** does not
 designate permitted sender hosts)
x-tm-as-product-ver: CSC-0-6.0.1038-17392
x-tm-as-result: Yes-9.62-7.00-31-1
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

 =?UTF-8?B?MSBwcm9qZWt0dSBDWi4xLjEwLzIuMi4wMC8wNC4xMTExMSBieWxhIHDFmWVk?=

 =?UTF-8?B?w6FuYSBkbyBzdMOhZGlhICJTOC4xIEtvbnRyb2xhIDEuIHN0dXBuxJsgcHJv?=

 =?UTF-8?B?dmVkZW5hIi4=?=
Received: from phpmailer ([*****])

        by ***** with HTTP (phpmailer);

        Wed, 19 May 2010 15:03:53 +0200

Date: Wed, 19 May 2010 15:03:53 +0200

From: *****

Message-ID: <c4bdf1fff95394c018522634ebbd39f4@*****>

X-Priority: 3

X-Mailer: phpmailer [version 1.65]

X-Mailer: PHP/5.1.6

MIME-Version: 1.0

Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 11:01:25 2019 UTC