Hi all,
I notice PHP mail() function works well with text/plain mails but not with text/html. To be more specific, mail() returns okay but in fact mails are not sent at all.
Are there any specific reasons mail server will not deliver text/html mails ?
This is the code I used to test:
I notice PHP mail() function works well with text/plain mails but not with text/html. To be more specific, mail() returns okay but in fact mails are not sent at all.
Are there any specific reasons mail server will not deliver text/html mails ?
This is the code I used to test:
Code:
$from = "from";
$to="to";
$mailbody="Test message sent (PST): \n" . date('l jS \of F Y h:i:s A');
$subject="Test of PHP mail()" ;
$headers = "Content-type: text/html; charset=iso-8859-1 \r\n";
$headers .= "From: $from\r\n";
$headers .= "Reply-To: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
if( mail($to, $subject, $mailbody, $headers))
echo "success";
else
echo "failed";
Last edited: