« NTLM transaction using CURL | Main | LEFT JOINS and MySQL 5+ »

April 26, 2007

Sending plain text and HTML version in the same email

Sending HTML/Plain text Emails - PHP

$boundary = "nextPart";

$headers = "FROM: [email]me@fromme.com[/email]\r\n";

$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-Type: multipart/alternative; boundary = $boundary\r\n\r\n";

$headers .= "This is a MIME encoded message.\r\n\r\n";

//text version

$headers .= "--$boundary\n

            Content-Type: text/plain; charset=ISO_8859-1\r\n

            Content-Transfer_Encoding: 7bit\r\n\r\n";

$headers .= "This is the plain version\r\n\r\n";



// html version

$headers .= "--$boundary\r\n

            Content-Type: text/html; charset=ISO_8859-1\r\n

            Content-Transfer_Encoding: 7bit\r\n\r\n";

$headers .= "This is the HTML version";

mail("me@myemail.com", "An HTML Message", "", $headers); 

Tags: PHP

Posted by pj at April 26, 2007 10:58 AM

Comments