[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 16:48: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: 4.7.3
Component: Mail | Version: 4.7.2
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+--------------------
Comment (by Andy Schmidt):
To avoid the possibility of side effects with legacy Linux mailers that
might mangle RFC compliant line endings, you could either use the
operating system line-end as the default value, e.g.:
$phpmailer = new PHPMailer( true );
<<insert here>>
$phpmailer->LE = PHP_EOL;
In essence, you would leave the default of \n in place for Linux, and
would only change it to \r\n, which is proper for SMTP, which is the
method used by Windows.
You could also make it operating system dependent, if you prefer:
$phpmailer = new PHPMailer( true );
<<insert here>>
if ( stripos(PHP_OS, 'WIN') === 0 ) { // Windows uses SMTP, mandating
RFC compliant line ending
$phpmailer->LE = '\r\n';
}
Explanation: Linux implementations are not affected by the change in PHP 7
because they launch command line mailers which have always been prepared
to accept lines terminated by \n (their operating system default) as
input. Those mailers will output proper \r\n when mailing anyway.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39753#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list