Doc #81158 [Com]: Mails sent by mail function broken since PHP 8.0

From: Date: Thu, 17 Jun 2021 22:03:51 +0000
Subject: Doc #81158 [Com]: Mails sent by mail function broken since PHP 8.0
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18873@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81158&edit=1

 ID:                 81158
 Comment by:         php at shyim dot de
 Reported by:        php at shyim dot de
 Summary:            Mails sent by mail function broken since PHP 8.0
 Status:             Open
 Type:               Documentation Problem
 Package:            Mail related
 Operating System:   Debian 10 (Docker)
 PHP Version:        8.0.7
 Block user comment: N
 Private report:     N

 New Comment:

You are correct. ssmtp and busybox sendmail doesn't care about CRLF. Where the postfix sendmail
does the job correct.


Previous Comments:
------------------------------------------------------------------------
[2021-06-17 21:26:45] cmb@php.net

The fix for the bug, which has been reported more than ten years
ago, had deliberately been delayed to PHP 8 (a new major version).
It should probably get a changelog entry, but I am against
reverting this fix.  If your mail software replaces CRLF with
CRLFCRLF, or whatever, in mail headers, consider to report that
bug upstream.

------------------------------------------------------------------------
[2021-06-17 21:13:44] php at shyim dot de

The headers are in CRLF in the example. Or was it a general comment?

------------------------------------------------------------------------
[2021-06-17 20:40:30] tiffany@php.net

Please keep in mind that CRLF for email headers is what's specified in the email RFC.

https://datatracker.ietf.org/doc/html/rfc2822#section-2.2

------------------------------------------------------------------------
[2021-06-17 20:15:13] php at shyim dot de

Here is a screenshot of the sent mail. The headers have always two new lines instead one:
https://i.imgur.com/iQEaUyi.png

------------------------------------------------------------------------
[2021-06-17 20:13:02] php at shyim dot de

Description:
------------
Setup:

- Mailhog
- SSMTP
- Configured php.ini to ssmtp -t

Execute the test script with 7.4 and 8.0. The email looks correct in 7.4 and its totally broken on
8.0. The headers are in the body in PHP 8.0.

Test script:
---------------
$to      = 'nobody@example.com';
        $subject = 'the subject';
        $message = 'hello';
        $headers = 'From: webmaster@example.com' . "\r\n" .
            'Reply-To: webmaster@example.com' . "\r\n" .
            'X-Mailer: PHP/' . phpversion();

        mail($to, $subject, $message, $headers);

Taken from https://www.php.net/manual/en/function.mail

Expected result:
----------------
The mail is the same on both PHP versions

Actual result:
--------------
It's totally different. The PHP 8.0 doesn't have a subject. I guess it has something done
with https://github.com/php/php-src/commit/6983ae751cd301886c966b84367fc7aaa1273b2d#diff-c6922cd89f6f75912eb377833ca1eddb7dd41de088be821024b8a0e340fed3df


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81158&edit=1


Thread (11 messages)

« previous php.doc.bugs (#18873) next »