|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-06-17 20:13 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 21:00:01 2025 UTC |
Add a mail header in the mail function: $header = "From: noreply@example.com\r\n"; $header.= "MIME-Version: 1.0\r\n"; $header.= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $header.= "X-Priority: 1\r\n"; $status = mail($to, $subject, $message, $header); if($status) { echo '<p>Your mail has been sent!</p>'; } else { echo '<p>Something went wrong. Please try again!</p>'; } (https://www.mycenturahealth.us/)github.com