Yahoo receives empty mail?
Posted: Tue Dec 09, 2003 10:39 am
Hi there,
I'm a volunteer for a non profit organisation. I've made a mail script to mass mail our volunteers (just about 200). All volunteers get their mail, but those with a yahoo account get an empty mail.. Is there something wrong with the headers? I got part of this code from php.net
They have the possibility to add an attachment, and the heading of the mail is always the official heading...
This is the code:
I'm a volunteer for a non profit organisation. I've made a mail script to mass mail our volunteers (just about 200). All volunteers get their mail, but those with a yahoo account get an empty mail.. Is there something wrong with the headers? I got part of this code from php.net
They have the possibility to add an attachment, and the heading of the mail is always the official heading...
This is the code:
Code: Select all
$from_name = "Mobileschool";
$from_email = $_POSTї'from'];
$subject = $_POSTї'subject'];
// headers need to be in the correct order...
$headers = "From: $from_name<$from_email>\n";
$headers .= "Reply-To: <$from_email>\n";
$headers .= "MIME-Version: 1.0\n";
// the following must be one line (post width too small)
$headers .= "Content-Type: multipart/related;type="multipart/alternative";boundary="----=MIME_BOUNDRY_main_message"\n";
//
$headers .= "X-Sender: $from_name<$from_email>\n";
$headers .= "X-Mailer: PHP4\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <$from_email>\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "------=MIME_BOUNDRY_main_message \n";
$headers .= "Content-Type: multipart/alternative; boundary="----=MIME_BOUNDRY_message_parts"\n";
// html section begins
$message .= "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/html;\n charset="iso-8859-1"\n";
//$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
// your html goes here -- It didn't appear properly without
// the weird markup that outlook added after sending
$message .= "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n";
$message .= "<HTML><BODY>\n";
$message .= "<table width="100%" border="0"><tr><td><img src="http://www.mobileschool.org/ms.jpg" border="0"></td> <td>MOBIELE SCHOOL PROJECT<br>VZW MOBILE SCHOOL<br>Rek.nr: 735-0051653-37<br>Naamsestraat 159 - 3000 Leuven - 016/500 234<br>info@mobileschool.org - www.mobileschool.org </td></tr></table><hr> ".nl2br(stripslashes($_POSTї'msg']));
$message .= "</BODY></HTML>\n";
$message .= "\n";
// this ends the message part
$message .= "------=MIME_BOUNDRY_message_parts--\n";
$message .= "\n";
// now we add attachments (images, etc)
if (!empty($_FILESї'userfile']ї'name'])){
$message .= "------=MIME_BOUNDRY_main_message\n";
$message .= "Content-Type: image/octetstream; \n name="".$_FILESї'userfile']ї'name'].""\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "\n";
// (truncated for space)
$Filename=$_FILESї'userfile']ї'tmp_name'];
$fd=fopen ($Filename, "r");
$FileContent=fread($fd,filesize($Filename));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$message.=$FileContent;
$message.="\n\n";
}
$message .= "\n";
//message ends
$message .= "------=MIME_BOUNDRY_main_message--\n";
/* and now mail it */
$i=0;
while (isset($_POSTї$i])){
set_time_limit(10);
mail($_POSTї$i], $subject, $message, $headers);
$i++;
}