Hey all,

Trying to send emails with attachments, first try at this. And am trying to adapt sample code I found here:


Trying this:

($data contains the contents of the file; I've verified this)

$hash = md5(date('r', time()));
$attachment = chunk_split(base64_encode($data));
$body_attachment = "--PHP-mixed-$hash--\n" .
"Content-Type: application/octet-stream; name=\"$filename\"\r\n" .
"Content-Transfer-Encoding: base64\n" .
"Content-Disposition: attachment\n".
$attachment . "\n" .

I then append $attachment this to the end of the email body and send it on. I've verified it is reading the file properly, in this test case it is a place text file. But I've tried a PDF and that did not work as well.

What happens is the email comes through and shows an attachment paper clip icon in Thunderbird, but when the email is clicked on the icon disappears and the email is empty, even the body is not there and no attachment either.

A final question I have is does the content-type value need to change for text files, Word Docs, PDFs, Excel files, etc, or is there one type that can handle any file type?

Any help would be great. I'm rather stuck and floundering here.


Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to