By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,681 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

mime multipart shows up as attachment

P: n/a
Hi!

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
send:

FROM: me <fo*@bar.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MIME_BOUNDARY"
--MIME_BOUNDARY
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

This is a multi-part message in MIME format.
navision://client/run?etcetc

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

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

--MIME_BOUNDARY--

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!
Klaus.
Aug 1 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
*** Der tolle Emil escribió/wrote (Tue, 1 Aug 2006 13:54:28 +0200):
FROM: me <fo*@bar.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MIME_BOUNDARY"
Try: multipart/alternative
--MIME_BOUNDARY
This --MIME_BOUNDARY should not be here.
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

This is a multi-part message in MIME format.
navision://client/run?etcetc
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.
>
--MIME_BOUNDARY
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

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

--MIME_BOUNDARY--
This is a message generated by The Bat! mail client, use it as template:
Date: Tue, 1 Aug 2006 19:48:29 +0200
From: "Alvaro G. Vicario" <alvaro@*************>
X-Mailer: The Bat! (v2.01.3) Personal
Organization: http://www.demogracia.com/
X-Priority: 3 (Normal)
Message-ID: <12***********************@demogracia.com>
To: Alvaro G Vicario <alvaro@*************>
Subject: Mixed HTML and text
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----------1271226D31E3D293"

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

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

<html><head>
</head>
<body BGCOLOR=#D2C1EC>
This is the <b>message</bbody. </body></html>
------------1271226D31E3D293--
--
-+ 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
--
Aug 1 '06 #2

P: n/a

"Alvaro G. Vicario" <we*******@NOSPAMdemogracia.comschrieb im Newsbeitrag
news:q9*****************************@40tude.net...
*** Der tolle Emil escribió/wrote (Tue, 1 Aug 2006 13:54:28 +0200):
>FROM: me <fo*@bar.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MIME_BOUNDARY"

Try: multipart/alternative
>--MIME_BOUNDARY

This --MIME_BOUNDARY should not be here.
>Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

This is a multi-part message in MIME format.
navision://client/run?etcetc

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.
>>
--MIME_BOUNDARY
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

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

--MIME_BOUNDARY--

This is a message generated by The Bat! mail client, use it as template:
Date: Tue, 1 Aug 2006 19:48:29 +0200
From: "Alvaro G. Vicario" <alvaro@*************>
X-Mailer: The Bat! (v2.01.3) Personal
Organization: http://www.demogracia.com/
X-Priority: 3 (Normal)
Message-ID: <12***********************@demogracia.com>
To: Alvaro G Vicario <alvaro@*************>
Subject: Mixed HTML and text
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----------1271226D31E3D293"

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

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

<html><head>
</head>
<body BGCOLOR=#D2C1EC>
This is the <b>message</bbody. </body></html>
------------1271226D31E3D293--
--
-+ 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
--

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.
Aug 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.