Funny, I just had to figure out today how to nicely do HTML e-mails. I
ended up using PEAR:Mail_mime, and it worked pretty well. It will also
work for your attachments. I believe that PHP itself recommends it on
their mail() function reference page.

Adam.

On Mon, Aug 10, 2009 at 6:49 PM, Skip Evans<s...@bigskypenguin.com> wrote:
> Hey all,
>
> Trying to send emails with attachments, first try at this. And am trying to
> adapt sample code I found here:
>
> http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php
>
> 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" .
> "--PHP-mixed-$hash--\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.
>
> Thanks,
> Skip
>
> --
> ====================================
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://bigskypenguin.com
> ------------------------------------
> 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
>
>



-- 
Adam Randall
http://www.xaren.net
AIM: blitz574

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

Reply via email to