[php-src] Issue #8086: Mail() functio nnot working in PHP 8.x
| From: | hansherlighed | Date: | Sat, 12 Feb 2022 07:04:15 +0000 |
| Subject: | [php-src] Issue #8086: Mail() functio nnot working in PHP 8.x | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-239707@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8086
Author: hansherlighed
### Description
The following code:
```php
<?php
mail("someone@example.com", "This is the subject", "This is the
body");
>?
```
Resulted in this output of the DATA part of the communication from tcpdump on the receiving SMTP
server when building container "FROM php:8.0.14-fpm-alpine" or "FROM
php:fpm-alpine":
```
Received: by f3de6efeb3a0 (sSMTP sendmail emulation); Sat, 12 Feb 2022 06:28:10 +0100\r\n
From: "Linux User" <www-data@f3de6efeb3a0>\r\n
Date: Sat, 12 Feb 2022 06:28:10 +0100\r\n
To: redacted@example.com\r
\r\n
Subject: This is the subject\r
\r\n
\r
\r\n
This is the Body\r
\r\n
\r\n
```
This is the output using the exact same environment, just that the container is build using
"FROM php:7.4-fpm-alpine":
```
Received: by ae23725475da (sSMTP sendmail emulation); Sat, 12 Feb 2022 06:27:33 +0100\r\n
From: "Linux User" <www-data@ae23725475da>\r\n
Date: Sat, 12 Feb 2022 06:27:33 +0100\r\n
To: redacted@example.com\r\n
Subject: This is the subject\r\n
\r\n
This is the Body\r\n
```
The result is that when using PHP 8 the mail format is invalid and the headers are not processed
correctly on the receiving SMTP server. I've tried using both sendmail and ssmtp in the
container. It yields the same result.
My php.ini setting are:
```
sendmail_path = '/usr/sbin/sendmail -t -i -S myserver:25'
```
Something has changed in the PHP mail() function between PHP 7 and PHP 8
### PHP Version
PHP 8.0.14 and newer
### Operating System
Docker php:8.0.14-fpm-alpine and php:fpm-alpine