John Daniels
John Daniels

Reputation: 67

Whats wrong with my multipart/alternative Email?

I'm trying to build up my own Email sending class and it seems I have a bug with my MIME. If someone could find the error or tell me about a working MIME Validator I would really appreciate that.

Thanks in advance JD

To: [email protected]
Subject: Test Alternate
X-PHP-Originating-Script: 1000:SendMail.class.php
MIME-Version: 1.0
From: [email protected]
Content-Type: multipart/mixed;
 boundary="MultipartMail53dfa8ade817e"
Message-Id: <20140804153717.EA93E160195@myDevice>
Date: Mon,  4 Aug 2014 17:37:17 +0200 (CEST)
X-RCPT-TO: <[email protected]>
Status:  
X-UIDL: 706801872
X-IMail-ThreadID: c9b40003d631c851

--MultipartMail53dfa8ade817e
Content-Type: multipart/alternative;
 boundary="Alternative53dfa8ade8378"


--Alternative53dfa8ade8378
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Some Text content


--Alternative53dfa8ade8378
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit


Das ist Text
-- 

Text

*Some more Text*
Text



--Alternative53dfa8ade8378--

--MultipartMail53dfa8ade817e--

Upvotes: 1

Views: 2859

Answers (1)

jstedfast
jstedfast

Reputation: 38618

There's a few things "wrong" with your email:

Firstly, you have a non-header in your header:

To: [email protected]
*Test Alternate*
X-PHP-Originating-Script: 1000:SendMail.class.php

(*'s around the broken bit)

Secondly, (and probably your main issue with Thunderbird) is that your multipart/alternative has the child parts in the wrong order. The way that multipart/alternative is supposed to work is that the last part is supposed to be the form that is closest to what the original author of the message intended for you to see (IOW what he/she saw in their WYSIWYG editor).

TL;DR

Put the text/html part last and the text/plain part first within the multipart/alternative.

Upvotes: 3

Related Questions