php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63778 RFC-2822 does NOT permit LF without CR
Submitted: 2012-12-15 15:09 UTC Modified: 2012-12-19 01:27 UTC
From: Andy_Schmidt at HM-Software dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: Andy_Schmidt at HM-Software dot com
New email:
PHP Version: OS:

 

 [2012-12-15 15:09 UTC] Andy_Schmidt at HM-Software dot com
Description:
------------
---
From manual page: http://www.php.net/function.mail#refsect1-function.mail-parameters
---

Your manual incorrectly states for the "Message" parameter:

"Each line should be separated with a LF (\n). Lines should not be larger than 70 characters." 

Refer to the governing Internet standard on SMTP emails:
http://www.ietf.org/rfc/rfc2822.txt
2.1 "A line is a series of
   characters that is delimited with the two characters carriage-return
   and line-feed; that is, the carriage return (CR) character (ASCII
   value 13) followed immediately by the line feed (LF) character (ASCII
   value 10)."

and it clarifies further:
2.3 "CR and LF MUST only occur together as CRLF; they MUST NOT appear
     independently in the body."

Your manual should be updated to read:

"Each line should be separated with a CRLF (\r\n). Lines should not be larger than 78 characters."




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-17 20:27 UTC] mail+php at requinix dot net
Actually no. What you're missing is that PHP itself does not send the email. It 
goes through sendmail (and whatever application that may be). MTAs will convert \n 
to \r\n but some do so regardless of the actual line ending used, so if you 
provide \r\n yourself then it may become \r\r\n.

Using \n is best for compatibility.
 [2012-12-18 14:29 UTC] Andy_Schmidt at HM-Software dot com
I beg to disagree and hope to be clarify with this follow-up.

I believe we do agree that this section of the manual gives specific samples with respect to SMTP headers - it IS about SMTP messages. In this case, there are written standards the designate the proper format of such messages - revised SPECIFICALLY to clarify previous ambiguity regarding the line-end (because of programmers in certain operating systems getting it consistently wrong).

If you can, would you kindly point me to the standard that defines that MTAs "must" or even "should" REPLACE single LF with LF/CR combinations? I have run into very many that do NOT (which is the reason why I see hundreds of these malformed message bodies in our gateway filters every single day - usually from PHP form handlers).

IF there are MTAs out there that have a LF to CF/LF "fix-up" feature that the standards neither call for nor require, then this optional feature obviously should have been implemented in a way that VALID message bodies are NOT garbled by it. It would be trivial to fix this bug so that only stand-alone LFs are translated, but existing CF/LFs are not.

I therefore submit that any MTA that takes a VALID message body (with CR/LF line endings) and turns it into CF/LF/LF is itself not standards compliant and such a bug should be reported -- instead of perpetuating this incorrect behavior in the PHP manual.
 [2012-12-19 01:20 UTC] aharvey@php.net
Since we just went through this process with headers (long story short: we still recommend \r\n there), we should line the message documentation up with that.
 [2012-12-19 01:20 UTC] aharvey@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: aharvey
 [2012-12-19 01:27 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=328840
Log: Make the line endings recommended in mail() consistent in all the parameters.

Fixes doc bug #63778 (RFC-2822 does NOT permit LF without CR).
 [2012-12-19 01:27 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2012-12-19 01:27 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC