attachment filename
| From: | ROBERT MCPEAK | Date: | Tue, 16 Apr 2002 18:45:01 +0000 |
| Subject: | attachment filename | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-93237@lists.php.net to get a copy of this message | ||
The code below very nicely sends an email attachment, but, the name of
the attachment appears as "Part.000," not the original filename of the
attached file.
How do I set the filename of the attachment? I'd like it to be
something nice, like "yourfileattachment.txt" or something, not
"Part.000." What is Part.000 anyway?
Stumped!
Help!
Thanks!
Code:
//attachment
$to = $the_email;
$subject = 'dump';
$message = 'this is the dump';
$email = 'rmcpeak@jhuccp.org';
$boundary ="b" . md5(uniqid(time()));
$mime = "Content-type: multipart/mixed; ";
$mime .= "boundary = $boundary\r\n\r\n";
$mime .= "This is a MIME encoded
message.\r\n\r\n";
//first reg message
$mime_message .="--$boundary\r\n";
$mime .="Content-type: text/plain\r\n";
$mime .="Content-Transfer-Encoding: base64";
$mime .="\r\n\r\n" .
chunk_split(base64_encode($message)) . "\r\n";
//now attach
$filename = "mysqldump/surveydump.dmp";
$attach = chunk_split(base64_encode(implode("",
file($filename))));
$mime .="--$boundary\r\n";
$mime .="Content-type:
application/octet-stream;\r\n";
$mime .="Content-Disposition: attachment\r\n";
$mime .="Content-Transfer-Encoding: base64";
$mime .="\r\n\r\n$attach\r\n";
mail($to,
$subject,
"",
$mime);
//attachment