This is one of the strange problems i have faced in PHP.
When you try to send HTML mails using mail() function in PHP you get HTML code in the main instead of showing HTML Content.
It may happen because of some missing headers but it may happen because of some restrictions on mail server also.
So to cross check it you need to check following things first..
Check if you have provided proper headers and other things are proper or not.
Generally your code should be similar to this:
$headers = "From: from@address.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$to = "to@address.com";
$subject = "Any Subject";
$message=$html_code;
// ok now send the mail
mail ($to,$subject,$message,$headers);
If still same and you find no errors then try to upload it on some test server and see whether it’s working or not.
and still doesn’t work then there could be problem with your web host’s mail server.
It doesn’t happen with all the servers but few servers like 1and1 do not allow mails with “\n� in the end of each header.
So you just need to remove “\nâ€? from the end of each header and keep only “\r”, it should slove your problem. 🙂
I hope this helps you.
Deep
Thanks,
I was getting the same error, but I was able to solve this issue after reading this. However I used some other ways.
Karamvir Singh