When we send only html email, it still have problems. How if someone is using a mail client that cannot understand HTML email. To solve this problems, it is best to send any HTML email as dual format. This means providing both a text and an HTML version in the same email. Your client can choose which version to display.
<?php
// Setting a timezone, mail() uses this.
date_default_timezone_set('America/New_York');
// recipients
$to = "you@phpeveryday.com" . ", " ; // note the comma
$to .= "we@phpeveryday.com";
// subject
$subject = "Test for HTML Format";
// Create a boundary string. It needs to be unique
$sep = sha1(date('r', time()));
// Add in our content boundary, and mime type
//specification:
$headers .=
"\r\nContent-Type: multipart/alternative;
boundary=\"PHP-alt-{$sep}\"";
// additional headers
$headers .= "To: You <you@phpeveryday.com>,
We <we@phpeveryday.com>\r\n";
$headers .= "From: Me \r\n";
$headers .= "Cc: he@phpeveryday.com\r\n";
$headers .= "Bcc: she@phpeveryday.com\r\n";
// Your message here:
$body =<<<EOBODY
--PHP-alt-{$sep}
Content-Type: text/plain
Hai, It's me!
--PHP-alt-{$sep}
Content-Type: text/html
<html>
<head>
<title>Test HTML Mail</title>
</head>
<body>
<font color='red'>Hai, it is me!</font>
</body>
</html>
--PHP-alt-{$sep}--
EOBODY;
// Finally, send the email
mail($to, $subject, $body, $headers);
?>