Skip to main content
Ben Nadel at the New York ColdFusion User Group (May. 2009) with: Mark Drew and Gert Franz
Ben Nadel at the New York ColdFusion User Group (May. 2009) with: Mark Drew Gert Franz

GMail Chooses ONLY Non-HTML Mail If Given The Option

By
Published in Comments (13)

Having to send out emails from web applications, I am often concerned with how email looks in non-html email viewers (less nowadays since everyone on their mom uses a good email client). To handle this issue, I send out my CFMails with both a formatted and non-formatted part:

<cfmail
	to="xxx@gmail.com"
	from="xxx@zzz.com"
	subject="CFMail Part Text"
	type="HTML">

	<!--- Send HTML part. --->
	<cfmailpart type="text/html">
		My girlfriend is <strong><em>wicked</em></strong> smart!
	</cfmailpart>

	<!--- Send plain text part. --->
	<cfmailpart type="text/plain"
		>My girlfriend is wicket smart!
	</cfmailpart>
</cfmail>

This sends out both types of email (HTML and plain text) in the same message and allows the user's mail client to decide which one is most appropriate. It seems that GMail always displays the "text/plain" version of the email. This is demonstrated by the fact that in my test emails, "wicked" is neither bold nor italic. Not only does it choose the "text/plain", it escapes any HTML tags in the plain part (not demonstrated above).

If, however, you send out an email with no options:

<cfmail
	to="xxx@gmail.com"
	from="xxx@zzz.com"
	subject="CFMail Part Text - Inline HTML"
	type="HTML">

	<!--- HTML is inline. --->
	My girlfriend is <strong><em>wicked</em></strong> smart!
</cfmail>

... It displays just as you would expect it to. So, clearly GMail can handle HTML formatting (as we all know). But, taking that one step to the side, if you send out an email with ONLY an HTML formatted section:

<cfmail
	to="xxx@gmail.com"
	from="xxx@zzz.com"
	subject="CFMail Part Text - HTML Part Only"
	type="HTML">

	<!--- Send HTML part as only option. --->
	<cfmailpart type="text/html">
		My girlfriend is <strong><em>wicked</em></strong> smart!
	</cfmailpart>
</cfmail>

... the email shows nothing at all!

So given the option, GMail will ONLY show plain text (or nothing at all). But, if not given an option, it will display formatted emails quite naturally.

I thought maybe this was due to some formatting preference that I had set, but I couldn't find one anywhere. This seems like a kind of strange thing to me. And, just to contract this to another mail client, Microsoft Outlook handles this perfectly.

Want to use code from this post? Check out the license.

Reader Comments

1 Comments

I was just noticing the same thing, and came across your blog to see what can be done about it. Apparently nothing!

10 Comments

Found a solution... the order of the mime parts matters. If you put the text/plain part before the text/html, gmail will display the html part. Nice!

1 Comments

Can You help me with how to code and send a html email newsletter to client examp if my client has abc@gmail.com

1 Comments

i just recently signed up with gmail and i am receiving emails in text format...how do i chnage my email setting to receive emails in html format???

1 Comments

Ok, I'm having the opposite issue... I'm trying to send a text-only email to gmail and nothing shows up. Suggestions?

15,902 Comments

@DGLDY,

Try switching the order of the CFMailPart tags in the CFMail body. If you look at @Tim's comment above, GMail seems to take the order of the tag very seriously (but not sure why).

1 Comments

It happens same in AOL too.

I send a newsletter in AOL having both the version in bodypart, and it displayed only the Plain-text version of the mail.
Even on viewing the mail sourcecode, it displays both the versions of email.

Now am sending only HTML version to both of them.

15,902 Comments

@Chiranjib,

It's really frustrating that these mail clients have all of their own particular behavior.

@To All,

Campaign Monitor has a pretty mind-blowing tool that allows you to test mail blasts in like 20 different mail clients:

http://www.campaignmonitor.com/testing/

I am not sure if you can use it outside of a Campaign Monitor campaign; but I would recommend checking it out.

1 Comments

@Ben
Thanks for this wonderful post. I was doing a research today for one of my clients and this answered some of my questions. They have a additional requirement where they wanted a button on the email message that would convert an HTML email to PLAIN TEXT. I do not know the exact reason why they want this. I think that it might be to see the plain text version in case the HTML version is scrambled.

Any suggestions??

15,902 Comments

@Arvind,

I cannot think of any thing that would allow you do that. Sometimes, at the top of an HTML email, people will provide a, "Having trouble reading this? Click here." link that takes the user out of email to the actual target web site with an online version of the email.

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel