Sending multipart html emails with PHP script

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi to all,
After hours of attempts and "googling", I'm still pulling my hair off my
head when I try to send multipart html emails.

It "works" on PCs with Outlook when I juste send a single "related"
mail: one part for the HTML body, and several for the images. However,
the images do not show on a Mac.

I also wanted to have an "alternate", plain text message. I've tried the
method described by Zend and PHPBuilder, but no luck...

I've included a sample of what the email looks like in the end.

Questions: what is the best way to organize the multiparts? Where does
the header stop and the message start ?

Many thanks in advance !

MIME-Version: 1.0
Subject: My subject

Content-Type: multipart/alternative; boundary="PIEALT57206"
This is a mulipart message in mime format


Content-Type: text/plain;Content-Transfer-Encoding: 8bit;

Your mail software is not HTML....


Content-Type: multipart/related; boundary="PIEREL57206"


Content-Type: text/html


(html code here)


Content-Type: image/jpeg; name="logo.jpg"
Content-Transfer-Encoding: base64
Content-Description: "Image num.9"
Content-ID: Image9

(base64 encoded image)



Re: Sending multipart html emails with PHP script


On 11/15/2004 01:51 PM, Damien wrote:
Quoted text here. Click to load it

I suspect that the part separators are wrong.

Anyway, if I were you I would not re-invent the wheel and use existent
classes for composing and sending HTML messages with embededed images
and alternate part texts like this one:


Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP /

PHP Reviews - Reviews of PHP books and other products /

Metastorage - Data object relational mapping layer generator

Re: Sending multipart html emails with PHP script

Manuel Lemos wrote:
Quoted text here. Click to load it

In what way ? I've tried "simple" ones and some generated from

Quoted text here. Click to load it

Thanks for the link, but I need to customize the body before it is sent.
For now, adapting the code is a bit over my head.

Any other idea ?

"Disk that's so old it's got marks from Noah's screwdriver on the side. "

Site Timeline