note 77889 rejected from ref.mail by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 20:05:31 +0000 |
| Subject: | note 77889 rejected from ref.mail by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155329@lists.php.net to get a copy of this message | ||
Note Submitter: eflores at sterlingandbaxter dot com
----
I need help. When I send the email the attachments and the multiparts are displayed as text. What am
I doing wrong? I have tried the double eols and still have no clue. Here is my code.
<?php
$txt="The report contains locations on the ground for at least 16 weeks and no more than 17
weeks. A summary of last 3 weeks productivity and its average is included. Size".strlen($data);
// Generate a boundary string
$mime_boundary = "<<<--==+X[".md5(time())."]\r\n\r\n";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\r\n\r\n".
"--".$mime_boundary."\r\n".
"Content-Type: text/plain; charset=\"iso-8859-1\"\r\n".
"Content-Transfer-Encoding: 7bit\r\n".
$txt."\r\n\r\n".
"--".$mime_boundary."\r\n";
// Base64 encode the file data
$data="Dummy Info";
$data = chunk_split(base64_encode($data));
$fileatt_type="application/vnd.ms-excel;";
$fileatt_name="startupLocations.xls";
// Add file attachment to the message
$message .= "Content-Type: ".$fileatt_type."\r\n" .
" name=\"".$fileatt_name."\"\r\n" .
"Content-Transfer-Encoding: base64\r\n" .
"Content-Disposition: attachment;\r\n" .
" filename=\"".$fileatt_name."\"\r\n\r\n" .
$data."\r\n" .
"--".$mime_boundary."\r\n";
// Add the headers for a file attachment
$reportName='Comissions';
unset($sendTo);
$sql = "SELECT * FROM distributionlist left join autoemailtabs
on distributionlist.reporttabid=autoemailtabs.id
WHERE tabname='".$reportName."';";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
$sendTo[] = $row['email'];
}
for($j=0;$j<sizeof($sendTo);$j++){
$headers = "From:eaflores@sterlingandbaxter.com\r\n".
"To:".$sendTo[$j]."\r\n".
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n".
"boundary=\"".$mime_boundary."\"\r\n";
mail($sendTo[$j],' STS Comissions ',$message,$headers);
}//ednFor
//END SEND EMAIL
?>