I've made a script to send a weekly newsletter. I don't want the subscribers to choose between text and html, I prefer to use the multipart MIME format. So I write the following code. But I've got 2 problems :
1 - It works with standard mail software (Outlook or NS) in HTML, but with Hotmail, for example, it shows nothing, neither in text format nor in html format !
2 - I've got in Outlook an attached file which is empty (dat00001.txt - 0 bytes).
I really don't understand.
Here's my code :
function send_mail($mail,$subject,$message_text,$message_html)
{
$limit = "NextPart".md5(uniqid(rand()));
$header .= "Date: ".date("l j F Y, G:i")."\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/alternative;\n";
$header .= " boundary=\"----=$limit\"\n\n";
$text_simple .= "This is a multi-part message in MIME format.\n";
$text_simple .= "------=$limite\n";
$text_simple .= "Content-Type: text/plain;";
$text_simple .= "charset=\"iso-8859-1\"\n";
$text_simple .= "Content-Transfer-Encoding: 8bit\n\n";
$text_simple .= $message_text;
$text_simple .= "\n\n";
$text_html = "------=$limite\n";
$text_html .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$text_html .= "Content-Transfer-Encoding: 8bit\n\n";
$text_html .= $message_html;
$text_html .= "\n\n\n------=$limite\n";
return mail($mail, $subject, $text_simple.$text_html, $header);
}