1

I am using the following code:

$useremail="xxx@gmail.com";
$admin_email="yyy@gmail.com";
$sub="some meassage";
$content=<design with tables>.................;

$reval=mail($useremail,$sub,$content,'From:'. $admin_email));

The code sends the email correctly, but it displays in text format not HTML format which is what I want.

I am using Content-type:

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From:'. $admin_email. "\r\n";
$reval=mail($useremail,$sub,$content,$headers);

In this method the email is not delivered.

James
  • 4,644
  • 5
  • 37
  • 48
Silambarasan
  • 767
  • 5
  • 19

1 Answers1

0

Try to replace :

$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

By :

$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Full code example :

$useremail="xxx@gmail.com";
$admin_email="yyy@gmail.com";
$sub="some meassage";
$content = "Good morning,<br />
<strong>This is an HTML msg sent by php mail.</strong><br />
Thanks :)";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"";
$headers .= 'From:'. $admin_email. "\r\n";

$reval=mail($useremail,$sub,$content,$headers);

if($reval)
{
    echo "mail sent";
}
else
{
    echo "error.";
}

it's work for me.

Zakaria Acharki
  • 66,747
  • 15
  • 75
  • 101