GMail Chooses ONLY Non-HTML Mail If Given The Option

Posted August 2, 2006 at 3:00 PM by Ben Nadel

Tags: ColdFusion

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> hot!
  • </cfmailpart>
  •  
  • <!--- Send plain text part. --->
  • <cfmailpart type="text/plain"
  • >My girlfriend is wicket hot!
  • </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> hot!
  • </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> hot!
  • </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.



Reader Comments

Tim
Aug 17, 2006 at 4:52 PM // reply »
1 Comments

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


Aug 17, 2006 at 4:54 PM // reply »
74 Comments

Yeah, it seems like a weird glitch doesn't it? I will let you know if I find anything out about it.


Tim
Aug 24, 2006 at 1:15 PM // reply »
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!


Oct 23, 2009 at 4:23 AM // reply »
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


Dec 1, 2009 at 5:43 PM // reply »
1 Comments

@Tim, nice find. Works like a charm. Thank you.


Dec 23, 2009 at 3:58 PM // reply »
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???


Apr 7, 2010 at 3:08 PM // reply »
1 Comments

Great, Tim thanks for share your aknowledge!!


Apr 14, 2010 at 7:24 PM // reply »
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?


Apr 15, 2010 at 9:24 PM // reply »
11,246 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).


May 5, 2010 at 7:55 AM // reply »
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.


May 7, 2010 at 10:18 PM // reply »
11,246 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.


Jun 24, 2010 at 2:23 PM // reply »
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??


Jun 29, 2010 at 10:06 AM // reply »
11,246 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.



Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 24, 2013 at 5:39 PM
Ask Ben: Manually Enforcing Basic HTTP Authorization In ColdFusion
@Adam Oops! My mistake! I hadn't gotten that far in my testing - I'm still baby stepping my way through the process. ... read »
May 24, 2013 at 5:13 PM
Ask Ben: Manually Enforcing Basic HTTP Authorization In ColdFusion
Hi Jason, Thanks for checking up on that, but I still stand firm on my position. :) There are actually two listLast()'s in use, and you're right that the one using a space as a delimiter is fine. ... read »
May 24, 2013 at 4:45 PM
Ask Ben: Manually Enforcing Basic HTTP Authorization In ColdFusion
@Ben I have been lurking your site for quite some time, and haven't stepped up to comment until today. Thanks for all the great info - keep it up! @Adam I believe you are mistaken... as the commen ... read »
May 24, 2013 at 11:21 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@WebManWalking, Ha ha, let's us never speak of justifying "##" notation again :P ... read »
May 24, 2013 at 11:18 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Ben, Ah, so it was indeed how I vaguely remembered it to be: A direct assignment value = users.id[ i ] causes value to retain the sticky datatype of the query column. Although unnecessary in ... read »
May 24, 2013 at 9:11 AM
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
@Brandon, Hi, No, I haven't been able to do that. I have just kept it as it is. ... read »
May 23, 2013 at 9:52 PM
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
@Muhmmadibn Did you figure out a solution to launching PDFs? I am running into the same issues myself. There is no way to close the PDF or go back once you launch it. Thanks in advance! ... read »
May 23, 2013 at 6:06 PM
The Girl Who Broke My Heart, And Made Me A Better Person
Good day,ladies and gentle men, my name is Dr AMADI the great spell caster in Africa, i have help so many people for different kind of problems,who say there is no solution to problems on earth, that ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools