$plain_text = "This is a plain text email.\r\nIt is very cool.";
$html_text = "<html><body bgcolor=silver>This is a plain text email.<br>It is very cool.</body></html>";
$semi_rand = md5(time());
$mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand";
$boundary_header = chr(34) . $mime_boundary . chr(34);
$body = "This is a multi-part message in MIME format.
--$mime_boundary
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
This is the text portion of the mixed message.
--$mime_boundary
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<html><body><p>This is the <b>HTML portion</b> of the mixed message.</p></body></html>
--$mime_boundary--";
mail("me@me.com", "Test Email", $body,
"From: you@you.com\n" .
"MIME-Version: 1.0\n" .
"Content-Type: multipart/alternative;\n" .
' boundary=$boundary_header');