Fixed email header bug which would become a major issue with PHP8

This commit is contained in:
Frank Schubert
2024-09-18 16:23:24 +02:00
parent ade1e0897f
commit 04ff6cf758

View File

@@ -122,6 +122,18 @@ class Emailnotification {
//$log->debug(print_r($headers, true));
$mail =& Mail::factory('mail', ["-f ".$this->email_from]);
/*
* PHP 8's mail() function now outputs proper line endings in headers (CRLF instead of LF).
* Mail_mail < 2.0 would detect a unix system and change the headers line ending to LF.
* On Mail submission to Exim (via sendmail), mail() adds its own headers first with CRLF line ending,
* making Exim treat every subsequent header's LF as an invalid line ending, adding a whitespace after the LF,
* making all our custom headers into one long header.
*
* See: https://www.exim.org/exim-html-current/doc/html/spec_html/ch-message_processing.html#SECTlineendings
*
* So we force CRLF line endings for headers here.
*/
$mail->sep = "\r\n";
$mail->send($this->email_to, $headers, $body);
}