ColdFusion Muse

Cfmail and Missing Line Breaks

Mark Kruger April 12, 2006 8:09 PM Coldfusion Tips and Techniques Comments (11)

Here's a quick tip I learned today on CF-Talk about CFMAIL and whitespace. If you are using CFMAIL to send plain text mail but you set the "suprressWhitespace" attribute to YES it will strip out the whitspace and cause the mail to be sent without line breaks. To fix it, simply wrap your cfmail tag in a cfprocessingdirective tag, like this:

<cfprocessingdirective suppresswhitespace="No">
<cfmail from="blah" to ="blah" subject="more blah">
even more blah with a linebreak
some more blah

sincerly

blah blah
</cfmail>

</cfprocessingdirective>
While I have not had this problem I now know the solution.

  • Share:

11 Comments

  • Raymond Camden's Gravatar
    Posted By
    Raymond Camden | 4/12/06 7:51 PM
    I think you also get this if you use the CF Admin setting to suppress white space.
  • Rob Wilkerson's Gravatar
    Posted By
    Rob Wilkerson | 4/13/06 6:34 AM
    Great Scott! I can't tell you how often I've *forced* line breaks (using chr(13)/chr(10)) because I had no idea what was causing them to be removed. And now I feel like an idiot because the reason makes so much sense. Since this was such a revelation to me I probably won't forget again, but nonetheless, this blog post is getting bookmarked. Seriously.
  • mkruger's Gravatar
    Posted By
    mkruger | 4/13/06 7:21 AM
    Ray - thanks, good point.

    Rob, Glad I could help. Before I posted this entry I googled around because I figured someone else was bound to have blogged it, but I didn't find anything. So I figured it was a good "nugget" to record for posterity :)
  • Michael White's Gravatar
    Posted By
    Michael White | 4/13/06 9:52 AM
    my boss wants me to send a text message to engineer's cell phones when emergencies come up and since I have no SMS gateway (can you do that with MX7 Standard?) I just email their cell phone number but the message isn't formatted as expected. I have whitespace management selected in the administrator. Might that also be the reason I get weird issues with line breaks in my pseudo-excel output when I export data (I sometimes just output plain text with .xls extension)?
  • siew's Gravatar
    Posted By
    siew | 6/6/06 5:30 AM
    a great tips ;) this save me using chr(13)/chr(10) on each line..
  • Andy's Gravatar
    Posted By
    Andy | 10/4/06 3:32 AM
    You've just saved my live :) I love google.
  • hibiscusroto's Gravatar
    Posted By
    hibiscusroto | 4/10/07 12:45 PM
    a helpful tip. muchos gracias!
  • Scott Knaub's Gravatar
    Posted By
    Scott Knaub | 2/8/08 12:56 PM
    This tip is very useful! We are upgrading some CF5 servers and experienced the issue with text email messages being sent with all of the text on one line. Your tip has helped us to quickly resolve this issue. Thanks!
  • Scott Knaub's Gravatar
    Posted By
    Scott Knaub | 2/8/08 12:56 PM
    This tip is very useful! We are upgrading some CF5 servers and experienced the issue with text email messages being sent with all of the text on one line. Your tip has helped us to quickly resolve this issue. Thanks!
  • Anthony's Gravatar
    Posted By
    Anthony | 5/16/09 12:28 PM
    thanks for the tip. This was a very aggravating issue to deal with.
  • Tony Miller's Gravatar
    Posted By
    Tony Miller | 6/21/10 5:35 PM
    Another "me too" post to say thanks for posting this information. We have a trouble ticket system that allows generation of tickets via e-mail, and using your tip made it finally work properly.