note 77889 added to ref.mail
| From: | eflores at sterlingandbaxter dot com | Date: | Tue, 18 Sep 2007 17:29:30 +0000 |
| Subject: | note 77889 added to ref.mail | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130570@lists.php.net to get a copy of this message | ||
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
?>
----
Server IP: 209.41.74.194
Probable Submitter: 24.153.187.228
----
Manual Page -- http://www.php.net/manual/en/ref.mail.php
Edit -- https://master.php.net/note/edit/77889
Del: integrated -- https://master.php.net/note/delete/77889/integrated
Del: useless -- https://master.php.net/note/delete/77889/useless
Del: bad code -- https://master.php.net/note/delete/77889/bad+code
Del: spam -- https://master.php.net/note/delete/77889/spam
Del: non-english -- https://master.php.net/note/delete/77889/non-english
Del: in docs -- https://master.php.net/note/delete/77889/in+docs
Del: other reasons-- https://master.php.net/note/delete/77889
Reject -- https://master.php.net/note/reject/77889
Search -- https://master.php.net/manage/user-notes.php