phpmailerphprfc5322

PHP mail() docs say that I should only use LF in the body, but RFC 5322 says otherwise.


PHP manual (http://php.net/manual/en/function.mail.php) says:

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

But actual RFC 5322 gives totallty different information:

2.3. Body The body of a message is simply lines of US-ASCII characters. The only two limitations on the body are as follows:
o CR and LF MUST only occur together as CRLF; they MUST NOT appear independently in the body. o Lines of characters in the body MUST be limited to 998 characters, and SHOULD be limited to 78 characters, excluding the CRLF.

So - RFC says that only \r\n should be used. I don't understand - how does php mail() work in the background?


Solution

  • how does php mail() work in the background?

    Exactly as you might expect from the cionfiguration. By default its simply a wrapper around the sendmail binary on most systems and a very simple MUA where an SMTP host is specified. While the former uses a LF as a line ending in its input, the latter requires a CRLF for its output - since line endings vary by OS, PHP provides a unified line ending for mail (LF)