views:

38

answers:

1

When sending SMTP messages you are supposed to set the Content-Type to multipart/alternative when sending HTML and TEXT or multipart/mixed when sending TEXT and attachements.

So what do you do if you want to send HTML, Text, and attachements? Use both?

+2  A: 

Use multipart/mixed with the first part as multipart/alternate and subsequent parts for the attachments. In turn, use text/plain and text/html parts within the multipart/alternate part.

A capable email client should then recognise the multipart/alternate part and display the text part or html part as necessary. It should also show all of the subsequent parts as attachment parts.

The important thing to note here is that, in multipart MIME messages, it is perfectly valid to have parts within parts. In theory, that nesting can extend to any depth. Any reasonably capable email client should then be able to recursively process all of the message parts.

Mike