[wp-trac] [WordPress Trac] #39753: wp_mail() under PHP 7 hosted on Windows creates malformed email messages
WordPress Trac
noreply at wordpress.org
Wed Feb 1 01:54:39 UTC 2017
#39753: wp_mail() under PHP 7 hosted on Windows creates malformed email messages
--------------------------+-----------------------------
Reporter: Andy Schmidt | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Mail | Version: 4.7.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Synopsis: WordPress’ wp_mail function uses the third party component
PHPmailer 5. PHPmailer 5 relies on the standard PHP mail() function for
final delivery. With PHP 7.x hosted on Windows, WordPress mails are being
rejected by providers, such as Gmail, due to RFC violations.
Reason: PHPmailer->LE (Version 5) defaults to a lone "LF" (\n) as the end-
of-line character. That is in violation of SMTP, which expressly forbids
lone LF characters. This known error in PHPmailer 5 and has been be
resolved with (not yet released) PHPmailer 6.
Fortunately for WP (and other CMS'), Linux has an operating system default
of "LF", so its mailer programs have always translated lone LF to CR/LF
when creating SMTP data streams.
And, in PHP 5, the Windows implementation of mail() has always "fixed"
lone "LF" by replacing them with CR/LF. Consequently, WordPress (et al)
have worked in both environments.
As of PHP 7, the Windows implementation of mail() requires standards
compliant input and no longer fixes malformed headers. The lone "LF"
characters of the incorrect PHPmailer 5 defaults now "bleed" through and
result in malformed SMTP data streams. (Linux is not effected, because PHP
continues to launch the operating system's mailer programs.)
At a future time PHPmailer 6 will be the final solution.
In the meantime, WordPress wp_mail needs to explicitly set $phpmailer->LE
= '\r\n' right after this line:
$phpmailer = new PHPMailer( true );
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39753>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list