Folks,
I have sent many emails over the years with PHP and never had an HTML problem. I launched a new Apache/PHP server the other day and emails send fine.
All emails send as plain text. Seems like the encoding isn't working.
Even with the:
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
Being set... the email sending is not HTML, but plain text.
I can take this same PHP script and run it on another server and I get an HTML email.
So I know my PHP script is correct. What server setting in PHP/Apache would cause all emails to be sent as plain text ?
Here is what the recipient receives on their end in the message area of the text email:
Content-type: text/html; charset=iso-8859-1
From: [email protected]
Message-Id: <[email protected]>
Date: Sun, 9 Sep 2018 11:45:28 -0400 (EDT)
<html><body><h1>Hello, World!</h1></body></html>
My script code:
$to = '[email protected]';
$subject = 'php test';
$from='[email protected]';
$headers ='';
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$from.' '. "\r\n";
$message = '<html><body>';
$message .= '<h1>Hello, World!</h1>';
$message .= '</body></html>';
mail($to, $subject, $message, $headers);