Ticket #2603 (closed defect (bug): invalid)

Opened 6 years ago

Last modified 5 years ago

Illegal CR-LF sequence sent to mail on Unix

Reported by: juliano Owned by: anonymous
Priority: normal Milestone:
Component: General Version: 2.0.2
Severity: normal Keywords: Microsoft Outlook wp_mail email mail wrap wordwrap LF CR SMTP has-patch
Cc:

Description

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?

Attachments

2603.diff Download (1.9 KB) - added by Nazgul 5 years ago.

Change History

  • Summary changed from Illegal CR-LF sequence sent to @mail on Unix to Illegal CR-LF sequence sent to mail on Unix

I have now written a plugin, called  CRCRLF, to work around this issue.

Nazgul5 years ago

  • Keywords has-patch added
  • Milestone set to 2.1

I created a patch based on the given plugin code.

comment:5   matt5 years ago

  • Milestone changed from 2.1 to 2.2
  • Milestone changed from 2.2 to 2.3
  • Status changed from new to closed
  • Resolution set to invalid
  • Milestone 2.3 deleted

We use PHPMailer now.

Note: See TracTickets for help on using tickets.