Change record status: 
Project: 
Introduced in branch: 
7.x
Introduced in version: 
7.103
Description: 

For email headers, PHP's API suggests that CRLF are used normally, but some MTAs incorrectly replace LF with CRLF. See #234403: drupal_mail_send() should separate headers with CRLF. This behavior was working in PHP 7.4 and lower.

PHP 8+ requires mail headers to be separated by CRLF, see: https://bugs.php.net/bug.php?id=81158 or this commit.

Drupal 7 now changes the mail headers line endings in PHP 8 from "\n" to "\r\n", to align with the RFC. In case a site will need to override this behavior, or revert to the previous configuration (where "\n" applied to all PHP versions), a new config variable was introduced, which can be used to opt-out of this change.

Placing the code below in settings.php, you can revert this change and use "\n" as mail headers line endings even when using PHP 8:

$conf['mail_headers_line_endings'] = "\n";
Impacts: 
Site builders, administrators, editors
Module developers
Site templates, recipes and distribution developers