Here is some other code I found in the book CorePHP that is supposed to do HTML email. But I can't get the message to come through - it seems to be gibberish or invisible. The mail comes, and I can see the header, subject etc.
I think maybe it is the character encoding? I added the $body text string and stuck that in the mail function but I am not seeing it when I download the email.
Any ideas?
<?php
//add From: header
$headers = "From: webserver@localhost\r\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
//unique boundary
$boundary = uniqid("COREPHP");
//tell e-mail client this e-mail contains
//alternate versions
$headers .= "Content-Type: multipart/alternative" .
"; boundary = $boundary\r\n\r\n";
//message to people with clients who don't
//understand MIME
$headers .= "This is a MIME encoded message.\r\n\r\n";
//plain text version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/plain; charset=UTF-7\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode(
"This is the plain text version!"));
//HTML version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/html; charset=UTF-7\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode(
"This the <b>HTML</b> version!"));
$body = "<h1>This the <b>HTML</b> version!</h1>";
//send message
mail("rlane@mind.net", "An HTML Message", $body, $headers);
print("HTML Email sent!");
?>