Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


HTML e-mail with a plain-text alternative

How can I send an HTML e-mail with a plain-text alternative? I know that some services such as MailChimp offer an alternative but how would I do this if I wanted to send from my own server?

Related course: http://teamtreehouse.com/library/html-email-design

Dan Gorgone

3 Answers

Dan Gorgone
Dan Gorgone
Treehouse Guest Teacher

Most services make adding a plain-text version basically a required part of the process, allowing you to create a version with the push of a button in fact. The MailChimp version of this is pretty slick, in fact.

If you are sending emails on your own, it depends on the service you use. I'm about 99% sure Gmail will automatically include a dynamically-created text version of any email you create within the app. Not sure what others do.

Fabio Carneiro may have more knowledge on this, however, if you're talking about sending these multipart messages on your own. I think it comes down to writing the actual script that will send whatever you want as "multipart-alternative MIME" type format. Again, I defer to Fabio on this one.

James Barnett
James Barnett
39,199 Points

Ivo Miranda - You might interested in checking out this code which uses PHP Mailer to send a multipart-alternative MIME email


James Barnett Many thanks for the info! I will take a better look at it soon just after I finish my android lessons :) I'm excited about them and despite I don't have much time I just can't stop watching it :P

Dan Gorgone Thanks Dan. Let's see what Fabio Carneiro has to say. I was thinking about sending that alternative on my own unless it is really very hard to do :z

Fabio Carneiro
Fabio Carneiro
Treehouse Guest Teacher

Hi Ivo,

Like Dan said, MailChimp (and pretty much every other ESP) will automatically create a plain-text version of your email for you. I can't speak for other services, but with MailChimp, you can edit the plain-text version in whatever way you want before the campaign is sent - you can also just send plain-text-only campaigns, if that's your thing.

You can certainly do it yourself, but there are more drawbacks to sending bulk email yourself than there are benefits.

The biggest is deliverability - whatever you send won't be coming from an IP that's been 'whitelisted' or seen as trustworthy by spam filter and email services, which will prevent a lot of what you send from getting through. It's likely that, in a short time, the IP you send from will be blacklisted.

There's also a lot of cost on your end, if you choose to do it yourself. Not necessarily monetary cost, but a lot of development time in order to be able to do it all correctly and by-the-book.

The thing about ESPs is that we all provide more than just an interface from which you can send email; the infrastructure that powers everything behind the scenes (dedicated sending IPs that are trusted, MTA servers, etc.) is the difference between sending from an ESP like MailChimp or just using Gmail or Outlook.com.

I'm sure you can guess what I think, but honestly, sending via an ESP - and it certainly doesn't have to be MailChimp - is your best option.

Hi Fabio! Thanks for your reply :)

I see your point. So I can send a plain text different from the HTML? I wanted to do HTML e-mails that some companies do like: giving a link to a HTML page in case something is wrong with images or if the client only accepts plain text send a plain text version with the link to the HTML page. Is this possible with mailchimp?

My main concerns in using an ESP are the following:

  1. The privacy of my e-mail list<br>
  2. I would like to use HTML pages in my own host so that emails would alternatively show that link
  3. The privacy/block of my content: For example, I have some clients that have adult related websites and escort businesses. All legal in their countries and hosts but sometimes, in this delicate markets there are very strict policies and I am afraid of losing my mailing lists, having accounts banned and so on...

On another hand, I completely understand the benefits of using such a service.

Do you have any suggestion in my case? I would love to centralize all my clients but I fear to have my account blocked and my clients that don't even have nothing to do with it also get injured.

Fabio Carneiro
Fabio Carneiro
Treehouse Guest Teacher

You can have a plain-text email that's different from the HTML version, yes; they can't be too different in content, though, because many spam filters watch for that kind of thing.

Speaking generally regarding email list privacy, the major ESPs are secure enough that it shouldn't be a big concern to you.

As far as adult content and MailChimp goes, you couldn't send it with us, regardless of its legality in the country of origin, as stated in our acceptable use policy. I can't really speak to the policies of other ESPs, but some may be okay with that sort of content - you'd have to check with them, and it'd be good to do so before sending your emails.

Yes of course. Thanks for your quick answers :)

I will probably give it a try at mailchimp for the non adult related clients.

Will you do more courses? Why don't you do a course about mailchimp service itself? Explaining the benefits of it and the system itself. I think it would be nice.

There is another topic where a guy was complaining about the copy pastes. I left my opinion there. He is right in a way and I think there are better ways to do it. But overall it was a good course for someone that already has some knowledge of HTML and CSS.

Note: It will also be nice to mention at least some competitors so that it isn't all about mailchimp.