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: 2021-09-26 04:22 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: cmb (profile)
Status: No Feedback Package: Mail related
PHP Version: 5.2.10 OS: win32 only
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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
 [2021-09-13 14:53 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-09-13 14:53 UTC] cmb@php.net
> […], but sendmail under NIX requires LF as the new line
> character.

Is this still true?  If so, it still violates internet standards,
and would be completely broken for mail() as of PHP 8.0.0[1].

[1] <https://github.com/php/php-src/pull/5338>
 [2021-09-26 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: Tue Mar 19 05:01:29 2024 UTC