|  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
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
30 + 27 = ?
Subscribe to this entry?

 [2009-07-27 17:37 UTC] nestor at sakimori-x dot com
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\\r\nzzz");

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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-08 11:17 UTC]
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2020-12-08 11:17 UTC]
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] <>
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Mar 22 16:03:38 2023 UTC