HTML Email attachment problem
| From: | Peter Atkins | Date: | Thu, 31 Jan 2002 23:43:57 +0000 |
| Subject: | HTML Email attachment problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-83034@lists.php.net to get a copy of this message | ||
All,
I'm building a tool that takes form input and sends out an html email with a
word doc attached.
It sends the text and html version of the email but I can't open the
attachment. It opens blank.
Anyone have a thought or two about this?
<php snippet>
if ($attachment) {
$fp = fopen($attachment, "rb");
$data = fread($fp, filesize($attachment));
$data = chunk_split(base64_encode($data));
fclose($fp);
// add the MIME data
$str .= "--" . $boundary . "\r\n";
$str .= "Content-Type: application/octet-stream; name=\"" .
$attachment ."\"\r\n";
$str .= "Content-Transfer-Encoding: base64\r\n";
$str .= "Content-Disposition: attachment; filename=\"" . $attachment
."\"\r\n\r\n";
$str .= $data . "\r\n";
}
</php snippet>
thanks,
-p