PHP mail html format not working
You've re-set your headers:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = "From: [email protected]\r\n"."X-Mailer: php";
You're missing a dot in that last line, which is over-writing the previous two:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: [email protected]\r\n"."X-Mailer: php";
Look at this example, this is sufficient to send mail in php:
<?php
//change this to your email.
$to = "[email protected]";
$from = "[email protected]";
$subject = "Hello! This is HTML email";
//begin of HTML message
$message ="
<html>
<body>
<p style=\"text-align:center;height:100px;background-color:#abc;border:1px solid #456;border-radius:3px;padding:10px;\">
<b>I am receiving HTML email</b>
<br/><br/><br/><a style=\"text-decoration:none;color:#246;\" href=\"www.example.com\">example</a>
</p>
<br/><br/>Now you Can send HTML Email
</body>
</html>";
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
//options to send to cc+bcc
//$headers .= "Cc: [email][email protected][/email]";
//$headers .= "Bcc: [email][email protected][/email]";
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "Message has been sent....!";
?>
I found the same problem with a specific mail server, in my case the solution was to set "\n" instead of "\r\n" as the end of line for the headers.