mime multipart shows up as attachment

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

Threaded View

I wrote a little function to send emails which works quite well. I already  
managed to send attachments correctly (also more than 1 per email) but I am  
not able to send a HTML mail containing a text only block for non-HTML  
clients. I will not post the PHP code as I think it is irrelevant, the error  
lies within the mail header and/or body, so here is the mail I do want to  

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MIME_BOUNDARY"
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

This is a multi-part message in MIME format.

Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

<a href="navision://client/run?etcetc">click me</a>


The first 3 lines are passed as the header to PHP's mail() function, whereas  
the rest is passed as the body (starting with the first --MIME_BOUNDARY  
line). If I send a mail this way I get the mail with the text/plain part  
displayed and an ATT<random#>.html attachment containing the text/html part.

What exactly am I doing wrong?

Thank you!

Re: mime multipart shows up as attachment

*** Der tolle Emil escribió/wrote (Tue, 1 Aug 2006 13:54:28 +0200):
Quoted text here. Click to load it

Try: multipart/alternative

Quoted text here. Click to load it

This --MIME_BOUNDARY should not be here.

Quoted text here. Click to load it

This stuff is supposed to provide a hint for MIME unaware clients. It's not  
where you put your text only version: MIME away clients will ignore it.

So you need an additional block for your plain text.

Quoted text here. Click to load it

This is a message generated by The Bat! mail client, use it as template:

Date: Tue, 1 Aug 2006 19:48:29 +0200
X-Mailer: The Bat! (v2.01.3) Personal
Organization: http://www.demogracia.com/
X-Priority: 3 (Normal)
Subject: Mixed HTML and text
MIME-Version: 1.0
Content-Type: multipart/alternative;

Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This is the message body.  
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 8bit

<body BGCOLOR=#D2C1EC>
This is the <b>message</b> body. </body></html>

-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com

Re: mime multipart shows up as attachment

Quoted text here. Click to load it

Thanks! That did it; I believe I tried multipart/alternative before but then  
changed it back because obviously I had another error and thus thought that  
it made no difference.  

Site Timeline