Illegal CR-LF sequence sent to mail on Unix
|Reported by:||juliano||Owned by:||anonymous|
|Severity:||normal||Keywords:||Microsoft Outlook wp_mail email mail wrap wordwrap LF CR SMTP has-patch|
The pluggable function wp_mail uses PHP's mail function.
According to Ben Cooke, the mail function requires different input when it is running on different operating systems: On Windows systems, you need to use the CR-LF, the Windows convention and as defined in the SMTP email standard. On Unix systems, you need to use the traditional Unix LF only - it will convert to use the CR-LF style that is required to send down the wire.
The Unix system will replace all of the LF characters into CR-LF, even if there is already a CR preceding it. That means a CR-LF sequence will be broken (Ben Cooke describes it as “hypercorrected”) into a CR-CR-LF sequence.
Many email clients accept the CR-CR-LF sequence without blinking.
However, Microsoft Outlook gets confused by this sequence. It doesn't accept headers that use this sequence (they get moved into the body) and it doesn't recognize end-of-paragraph markers.
The result is that emails from WordPress format poorly in Outlook.
I see three possible solutions:
1) Blame Microsoft Outlook. This is a popular option, but seems unfair given WordPress is failing to conform to the expected input of mail.
2) Put an OS-dependent check, and replace all the CR-LF with LF on a Unix system.
3) Use one of the available replacements for PHP's mail function which allegedly deal with these platform issues more gracefully. PHPMailer?
Change History (8)
- Summary changed from Illegal CR-LF sequence sent to @mail on Unix to Illegal CR-LF sequence sent to mail on Unix