GMail Chooses ONLY Non-HTML Mail If Given The Option

Posted August 2, 2006 at 3:00 PM

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:

 Launch code in new window » Download code as text file »

  • <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:

 Launch code in new window » Download code as text file »

  • <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:

 Launch code in new window » Download code as text file »

  • <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.

Download Code Snippet ZIP File

Post Comment  |  Ask Ben  |  Permalink  |  Other Searches  |  Print Page




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


Post Comment  |  Ask Ben

Recent Blog Comments
Nov 22, 2009 at 4:30 AM
jQuery Live() Method And Event Bubbling
dasegtezr ... read »
Nov 22, 2009 at 4:03 AM
jQuery Live() Method And Event Bubbling
C_fieri ... read »
Nov 22, 2009 at 1:56 AM
Learning ColdFusion 9: Using CFQuery In CFScript Can Enable SQL Injection Attacks
Why adobe would give you script equivalent of cfquery is beyond me. I love cfquery tag because it helps me wriite clean sql, and get away from the horrible jdbc queries If I wanted to write javali ... read »
Nov 22, 2009 at 1:45 AM
Streaming Text Using ColdFusion's CFContent Tag And The Variable Attribute
The reason you would want to do this is to stream. Ack json/xml files to ria clients I used thus technique before because putting json in response stream causes debugging info to come thru As well a ... read »
Nov 21, 2009 at 6:47 PM
Hal Helms - Real World Object Oriented Development, Sarasota - Day Five
@charlie griefer, Thank you.. ... read »
Nov 21, 2009 at 5:15 PM
Using ColdFusion Structures To Remove Duplicate List Values
@Jose Galdamez, Oh heh yeah I didn't paste the whole code. I should have defined the vars -- my bad. It's fixed thou. Thanks. ... read »
Nov 21, 2009 at 4:49 PM
Styling The ColdFusion 8 WriteToBrowser CFImage Output
Great work yet again Ben! Whilst I didn't use this whole code, I copied some of your regex code for a similar problem with the lack of an alt attribute and unescaped ampersands in CFIMAGE for Railo 3 ... read »
Nov 21, 2009 at 1:13 PM
My First ColdFusion Builder Extension - Encrypting And Decrypting CFM / CFC Files
@Ben, Because I am pedantic, I just want to make sure that everyone knows there is absolutely no encryption going on. There is only encoding and obfuscation. The cfencode tool only obfuscates your C ... read »