Forum Moderators: coopster

Message Too Old, No Replies

Can send html emails, but what about as attachments?

Send html code as a file

         

briesm

2:27 pm on Jul 5, 2005 (gmt 0)

10+ Year Member



Hey, right now I can send html within an email which is good, but can get a little tricky if I want to print it out in a nice format, because many email programs don't support html or mess up the layout to say the least.

What I'd like to do:

Take that html code, which I send in an email, but instead of simply displaying it, attach it as a file...either as it's own seperate .html file or even a pdf or something. Does anyone know if this can be done?

Edit: My Goal is to send a printer friendly form (which is essentially html-based) via email.

briesm

5:15 pm on Jul 5, 2005 (gmt 0)

10+ Year Member



Anyone know if this is possible?

Let me put it another way, have $message = the html code for a webpage.
$message is generated via values that are sent through the form. Currently, I can have $message appear in the email while keeping its html form. Is it possible to have $message attached as a .html file?

coopster

5:24 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, you can. The PHP mail() [php.net] function page has this Note and links that are very helpful:


Note: Email with attachments and special types of content (e.g. HTML) can be sent using this function. This is accomplished via MIME-encoding - for more information, see this Zend article [zend.com] or the PEAR Mime Classes [pear.php.net].

briesm

5:39 pm on Jul 5, 2005 (gmt 0)

10+ Year Member



I'm not great with php, let alone MIME encoding, but I did catch this snippit from the link. This is for an image though, so I'm wondering if it's possible to specify a content-type: html and source=$message or something. I'd also like to avoid using PEAR MAIL if at all possible as I think it would further complicate things.

Finally, notice that the second segment of the e-mail (the image) has an extra optional MIME header called Content-Disposition. This header is used to indicate to the e-mail client how it recommends the following segment be presented to the user. It can be set to either attachment (not part of the e-mail) or inline (included in the e-mail itself inline with the text).

Content-Type: image/jpeg; name="zendlogo.jpg";
Content-Transfer-Encoding: base64

Content-Disposition: attachment