How to CFMAIL Properly and Keep the SPAM in the Can

One of the most commonly used ColdFusion tags may also be one of the most misused. I say this because of the ColdFusion code that I've seen in production. It appears that a large number people think that all you need to do is open the CFMail tag and type in a to address the from address a subject and then close the tag. And then stuff your email message between the opening and closing tags. People do it this way as this is how they are shown, see the examples below.

Adobe LiveDocs CF7,8,9:

<cfmail to = "#form.mailto#"
from = "#form.mailFrom#"
subject = "#form.subject#">

This message was sent by an automatic mailer built with cfmail:
= = = = = = = = = = = = = = = = = = = = = = = = = = =
#form.body#
</cfmail>

Common blog example found via a typical Google search:

<cfmail
to = "name@yourdomain.com"
from = "name@yourdomain.com"
subject = "Example of CFMail Tag using Coldfusion 5.0"
server = "mail.yourdomain.com">

Email Message
</cfmail>

While both examples are technically correct and will send an email from your ColdFusion server they all lack what most people are trying to achieve in sending HTML formatted/pretty email messages and messages with attachments. There are precise ways in which the RFC (RFC-822) standard for sending e-mails dictates that these are to be done and ColdFusion allows you to follow the standard exactly. You just need to know how. I am not going to bore you with the RFC standard details, however if you are suffering from insomnia feel free to read them. What I will show you is how to send an HTML formatted email with the proper email message parts and optional file attachments so that it will safely pass most if not all SPAM filter tests and will render properly in mail clients.

The above code would generate email that looked like this when you examine the raw email source.

Return-Path: <some_address@somedomain.com>
Delivered-To: myaddress@mydomain.com
X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on
   mail.mymailserver.com
X-Spam-Level: **
X-Spam-Status: No, score=2.8 required=5.0 tests=HTML_MESSAGE,
   HTML_MIME_NO_HTML_TAG,MIME_HTML_ONLY,RDNS_NONE autolearn=no version=3.2.4
Message-ID: <1331187905.1191260207349870.JavaMail.root@mail.mymailserver.com>
Date: Mon, 7 Dec 2009 11:35:39 -0600 (CST)
From: John Doe <some_address@somedomain.com>
Reply-To: some_address@somedomain.com
To: myaddress@mydomain.com
Subject: Hows life
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

John Doe,<br><br>

Just wondering how things are going.

Looks good, right? However, there are some issues. There are HTML tags in the body of the message, but there is no text portion of the message. If you notice the header information you will see an item for X-Spam-Status and this indicates a score of 2.8. This score was not high enough yet to dictate that this was SPAM according to this SPAM servers rules (on other email servers it might get flagged as SPAM), but you will notice that the items it flagged were almost all HTML related items such as HTML only. In order to reduce the SPAM score you need to properly format your email messages.

[More]



Thanks Alagad

The wonderful folks at Alagad had a promotional give away of three Wenger SwissGear backpacks to help promote TaskForce at CF.Objective(). I won one of them! WooWoo! Thanks Alagad!



Adobe ColdFusion Builder Released

Today Adobe released ColdFusion Builder 1.0. It's been a long time coming and a lot of people have been patiently waiting for this day. Unfortunately Adobe should have waited longer and fixed more of the outstanding bugs and painful performance issues. Then to add to the insult, the price was set at $299 but that does include Flash Builder 4 Standard. However, I still find it way too high of a price for a product that does NOT measure up. As others will note Flash Builder 4 Standard cost $249 so essentially you are paying $50 for ColdFusion Builder. This is great if you wanted to buy Flash Builder. Many of us never touch Flash so this is not much of a bargain.

Then there are performance issues. ColdFusion Builder is painfully slow when it comes to rebuilding project workspaces. It works fine for little projects, but serious enterprise level web applications with thousands of files and folders, such as what I work on, ColdFusion Builder is just slow or worse yet if just fails and throws errors. I've recorded this as a bug and nothing has been done about the problem as far as I can tell.

[More]



CFUnited Voting for Topics Ending Today

This is another shameless plug by someone wanting to be a speaker at CFUnited. In case you haven't been following #CFUnited on Twitter voting for CFUnited topics ends today February 12. I have submitted my Homebrewed ColdFusion Monitoring presentation as a topic. If I get enough votes I will teach you how to write your own ColdFusion based monitoring tools so you can monitor your ColdFusion servers. So head on over to the CFUnited website and cast your votes I hope to see you there.

 

** UPDATE **

Vote has been extended to February 20th - so get over there and vote...  for me ;-)



Homebrewed ColdFusion Monitor Presentation Files

Recently I presented Homebrewed ColdFusion Monitoring to the Twin Cities CFUG and to the Online ColdFusion Meetup.  Both presentations went well and I've been asked to post my slides and example code. 

Attached to this post is a zip file that contains a PDF version of my slides and the example code plus the CFC I'm using to make a full featured monitoring application.  Please note that the code is for CF9 Enterprise.  There may be some things that won't work in earlier versions of CF or the standard edition of CF.
 
The recording for my live presentation is at http://experts.na3.acrobat.com/p34004904/
 
Enjoy and watch RIAForge.  I am planning to release this application to the ColdFusion Community for collaborative development.
 
Thank you to all that attended the presentations and for your wonderful feedback.
 
Wil
 

*UPDATE* - I just uploaded a new zip file with corrected code that actually works this time.

*Note: When I write little tools like this I'm usually writing it because there is something I absolutely need to see in order to complete another project. These little tools are not written as projects themselves and therefore may not be very pretty or as full featured as something that I was writing as a complete project. I just needed to get some code running that gave me back the data I needed to see. There are no warranties or promises. If you find is useful then great. If not, oh well. I know the code works on CF8 at the moment. It used to work on CF7, but I do not have a CF7 server anymore so I can not be certain.



More Entries