Small formatting issue with emails sent via ColdFusion 9 Mail.cfc

This post is more than 2 years old.

Using the new mail.cfc to send emails in ColdFusion 9? You may notice an odd formatting issue. Check out this screen shot:

I thought this was whitespace in my code, but turns out it is the code that implements mail in script. Find base.cfc in your cf install\customtags\com\adobe\coldfusion folder. Open it and go to line 417. (Note - the tags as script stuff changed in 901. So if you are still on 900, your line number may be different.) On line 417 you will see #mailbody# as a variable, tabbed over. Simply remove the tabs. Here is a slice of the file:

Quick note - the white space did not render perfectly on my blog - so you will just have to imagine that mailbody is the online code all the way to the left.

<cfmail attributeCollection="#tagAttributes#"> #mailbody# <cfloop array="#params#" index="mailparam"> <cfmailparam attributeCollection="#mailparam#"> </cfloop> <cfloop array="#parts#" index="mailpart"> <!--- Capture mailpart content into a local variable and delete body attribute ---> <cfif structkeyexists(mailpart,"body")> <cfset var mailpartbody = mailpart["body"]> <cfset structdelete(mailpart,"body")> </cfif> <cfmailpart attributeCollection="#mailpart#"> #trim(mailpartbody)# </cfmailpart> </cfloop> </cfmail>

This fixes it up. You still get some whitespace after the message, but that should be pretty much invisible to the end user. You could remove all the white space if you wanted to, but I thought that was overkill.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Raymond Camden posted on 8/28/2010 at 7:49 PM

Forgot to mention - I already logged a bug report for this.

Comment 2 by Aaron Greenlee posted on 8/28/2010 at 7:59 PM

What mail program are you using?

Comment 3 by Raymond Camden posted on 8/28/2010 at 8:04 PM

In the screen shot it is Thunderbird. I do NOT use it for my 'real' email. I'm using it here for testing.

Comment 4 by Jesse posted on 2/22/2011 at 8:26 PM

Did you log this bug on a public bug tracker, so I can check its status?

Comment 5 by Jesse posted on 2/23/2011 at 2:31 AM

Ah, I found it: bug #83967 at