Keep CRLF header separators in MailTransport so mail() output stays valid MIME - closes #5615

This commit is contained in:
FreeScout
2026-09-03 10:28:09 -07:00
parent 1d115c6be8
commit 8293c064d9

View File

@@ -157,7 +157,20 @@ class Swift_Transport_MailTransport implements Swift_Transport
if ("\r\n" != PHP_EOL) {
// Non-windows (not using SMTP)
$headers = str_replace("\r\n", PHP_EOL, $headers);
// PHP_EOL = \n
// Do NOT convert CRLF to LF in $headers: mail() emits the To:
// and Subject: headers it builds from $to/$subject using CRLF,
// so rewriting the remaining headers to bare LF yields a mix of
// both endings. Exim (and other MTAs) then read an LF-separated
// line as an obs-fold continuation of the previous header and
// prepend a space, which demotes Content-Type: multipart/... to
// a folded part of Message-ID:. The message loses its MIME type
// and clients render the raw source (boundaries, quoted-printable)
// instead of the body. See RFC 5322 2.2 and PHP >= 7.2 mail().
// https://github.com/freescout-help-desk/freescout/pull/5615
//
//$headers = str_replace("\r\n", PHP_EOL, $headers);
$subject = str_replace("\r\n", PHP_EOL, $subject);
$body = str_replace("\r\n", PHP_EOL, $body);
} else {