php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49076 "\n." is incorrectly replaced with "\n.."
Submitted: 2009-07-27 17:37 UTC Modified: 2020-12-08 11:17 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: nestor at sakimori-x dot com Assigned: cmb (profile)
Status: Wont fix Package: Mail related
PHP Version: 5.2.10 OS: win32 only - WinXP SP3
Private report: No CVE-ID: None
 [2009-07-27 17:37 UTC] nestor at sakimori-x dot com
Description:
------------
The SMTP spec states (sec. 4.5.2) that all instances of "<CRLF>." (not including the SMTP message-ending "<CRLF>.<CRLF>" sequence) should be replaced with "<CRLF>..". It seems PHP is replacing all instances of "<LF>." with "<LF>..", regardless of the presence of a "<CR>" character.
 
This was originally reported as bug #623 way back in 1998 and is still an issue.

Reproduce code:
---------------
mail($test_address, "test subject", "abc\n.jkl\r\n.xyz\r\nzzz");

Expected result:
----------------
An SMTP message containing "abc\n.jkl\r\n..xyz\r\nzzz" should be sent.

Actual result:
--------------
An SMTP message containing "abc\n..jkl\r\n..xyz\r\nzzz" is sent. This was confirmed with a packet sniffer (no server logs/reports or mail clients to muddy the waters).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-08 11:17 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2020-12-08 11:17 UTC] cmb@php.net
That is correct.  However, RFC 5321 also states in section
2.3.8[1] that clients must not send stand-alone LF characters.
This is not enforced by PHP's mail() implementation.

Given that mail() allows to send stand-alone LF since "forever",
that this ticket got almost no attention, and that automatically
replacement of LF with CRLF may actually break more working code
than fix it, we should leave this to user code.

[1] <https://tools.ietf.org/html/rfc5321#section-2.3.8>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC