Here is some code I use to send HTML formatted emails. Maybe it can be of help to you.
I have a file (I'll upload it so you can get an idea what I am doing) that serves as a "template" for the email. I use fopen() to read the file into my $body var and then replace some [TAGS] in the email.
Here is the code:
$headers .= "From: [email]support@maidenchase.com[/email]\nReply-To: [email]support@maidenchase.com[/email]\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
//$headers .= "MIME-Version: 1.0\r\n";
$subject = "Welcome to MaidenChase.com.";
// Get the welcome email body from saved .html file
if(!$fp = fopen("$GLOBALS[DOCUMENT_ROOT]/newuser/welcome.inc.html", "r")) {
//file open failed, create error routine here
Print ("File open failed very badly!");
exit;
}
while (!feof($fp))
{
$send_body .= fgets($fp, 100);
}
fclose($fp);
$send_body = eregi_replace("__s_user__", $s_user, $send_body);
$send_body = eregi_replace("__firstname__", $firstName, $send_body);
$send_body = eregi_replace("__lastname__", $lastName, $send_body);
$send_body = eregi_replace("__password__", $password, $send_body);
$send_body = eregi_replace("__answer__", $secret_a, $send_body);
$send_body = eregi_replace("__question__", $secret_q, $send_body);
$send_body = eregi_replace("__city__", $city, $send_body);
$send_body = eregi_replace("__state__", $state, $send_body);
$send_body = eregi_replace("__zip__", $zip, $send_body);
$sentMail = mail($email, $subject, $send_body, $headers);
}
}
The attached .html file is the template.
Maybe this will give you some ideas.
Kevin