I am using a function that I found to send html formatted emails. I plunked it in and it worked with no issue. Until it was tested by someone using Outlook or iMail, who got a LONG string of indecipherable data. I am using Gmail as my mail client, and I happily/ignorantly getting the nicely formatted emails.
The function:
Code: Select all
//MAILING FUNCTION
function sendHTMLemail($HTML,$from,$to,$subject)
{
$headers = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid("HTMLEMAIL");
$headers .= "Content-Type: multipart/alternative;".
"boundary = $boundary\r\n\r\n";
$headers .= "This is a MIME encoded message.\r\n\r\n";
$headers .= "--$boundary\r\n".
"Content-Type: text/plain; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode(strip_tags($HTML)));
$headers .= "--$boundary\r\n".
"Content-Type: text/html; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($HTML));
mail($to,$subject,"",$headers);
}
If you have experienced this, I'd love to know how you've solved this problem.
Thank you