I have had no success sending multipart/alternative emails with php. I have
tried everyone's various code snippets with no luck. I test the results with
Outlook and Outlook Express. Everytime my boundary tag ends up showing as
part of my message and thus the plain text and html portions show up as one
long blob of unformatted text. Below is the code I am currently using. Any
suggestions would be greatly appreciated. 

Thanks,

Dan

The code:

<?php 
error_reporting(E_ALL); 
//FUNCTION future
multipartmailer($to,$from,$subject,$plaintextsource,$htmlsource); 
//$boundry="**=-=-=D-=-=-=-MIME-A-Boundry-=-=-N=-=-=-**"; 
$boundry= "---=".uniqid("MAILDIVIDERS"); 
//set mime type 

$headers="From: Person <[EMAIL PROTECTED]>\n"; 
$headers.= "MIME-Version: 1.0\n"; 
$headers.="Content-Type: multipart/alternative;
boundary=\"$boundry\"\n"; 
//these files have the raw message content 
$plaintext = file("plaintextcontent.txt"); 
$html = file("htmlcontent.txt"); 
//warning for non-MIME lovin' clients 

$headers .= "This message is in MIME format. Since your mail reader does not
understand this format, some or all of this message may not be
legible.\n\r\n\r"; 

// CHOP 
$message .= $boundry."\n"; 
$message .= "Content-Type: text/plain; charset=ISO-8859-1\n"; 
$message .= "Content-Transfer-Encoding: 8bit\n\r"; 
foreach($plaintext as $line) { 
    $message .=$line; 
} 
$message .="\n".$boundry."\n"; 
$message .= "Content-Type: text/html; charset=ISO-8859-1\n"; 
$message .= "Content-Transfer-Encoding: 8bit\n"; 
foreach($html as $line) { 
    $message .=$line; 
} 
$message .="\n".$boundry."\n"; 
mail("[EMAIL PROTECTED]","Welcome to the Website",$message,$headers); 
print $headers."".$message."<br>"; 

?> 
</body> 
</html

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to