Which line break in php mail header, \r\n or \n?
The CRLF \r\n
, should be used according to the php documentation. Also, to conform to the RFC 2822 spec lines must be delimited by the carriage return character, CR \r
immediately followed by the line feed, LF \n
.
Since \r\n
is native to Windows platforms and \n
to Unix, you can use the PHP_EOL
Docs constant on Windows, which is the appropriate new line character for the platform the script is currently running on.
Just in case a search engine picks this up and saves someone else the frustration I went through: here's an additional curiousity.
On php 5.2x on Linux, I had \r\n on my email headers in php mail(), after an upgrade to php 5.3.3, the formatting and sending mysteriously failed. Removing the \r fixed the script (after examining many many other possibilities).