views:

397

answers:

7

I've used ColdFusion for sending text emails for years. I'm now interested in learning how to send those pretty emails you see from companies like Mint.

Anyone know of a good ColdFusion tutorial to teach me how to make this work and not get hit by bugs or spam filters?

+4  A: 

What do you mean by "pretty" - HTML based? CF supports html email. Just use type="html". You can also use cfmailpart to send both text and html versions of the same content.

CF Jedi Master
Tread carefully when sending multipart messages. It's rarely as simple as it sounds. If this is the route you want to take, I strongly recommend familiarizing yourself with the mutt mail client for *NIX and making sure that the plain text versions of your messages are being handled correctly. I can't tell you the number of times multipart email wackiness comes up as a topic on a mailing list of computer science alumni that I'm on.
Eric Kolb
+3  A: 

Here's a good article on making HTML email using CSS:

http://articles.sitepoint.com/article/code-html-email-newsletters

Ray's answer is right on the money about the CF part, but most of making this work is about HTML, CSS and testing testing testing.

bpanulla
+10  A: 

As Ray said, ColdFusion supports HTML email, which is how you make an email "pretty". A quick down and dirty sample looks like this:

<cfmail from="[email protected]" to="[email protected]" subject="Check this out!" type="HTML">
    <HTML>
       <head><title>My Email</title>

       </head>
       <body>
           <!--- Style Tag in the Body, not Head, for Email --->
           <style type="text/css">
               body { font-size: 14px; }
           </style>
           This is the text of my email.
       </body>
    </HTML>
</cfmail>

That's it, you've just sent an email. Notice how there is nothing preventing you from sticking in any old from email address you like? That leads me to my next point, in which you're wondering how to avoid getting hit by Spam filters:

The short answer is: You can't.

Oh sure, you can do intelligent things, like not including the word "VIAGRA" in your email (unless you're trying to send out penile enlargement emails and want to know how to get past spam filters, in which case I'm disinclined to help), but let's assume you just want to avoid obvious pitfalls.

I can think of two things that might help:

  • Send out email from a domain registered to the from email address. I didn't make the rules, but this one can be a pain. Ie., If you try to send out proxy emails for myorg.com, and your server does not host myorg.com, some spam filters are going to block it. What is usually done is to apply some branding to the from email, like this:

    <cfmail from="MyOrg.Com <[email protected]>" replyto="[email protected]" to="[email protected]" subject="Test" type="HTML"> </cfmail>

In this case the email is sent from your server at registeredsite.com, with a replyto being the proxy email address. Spam filters will probably be okay with this, since the from email address of *@registeredsite.com resolves to your server. Try to send out with [email protected] in the from, and you'll definitely run into some places that will block you.

  • Use a physical server, not a cloud site. I'm running into this very issue right now, but if you don't use a physical server that is located at a dedicated IP to send out your email, and if this server is not the originator of the email, some places are going to block it. This means no EC2 or Rackspace cloud site--sorry, some sysadmins are inclined to put down the banhammer on anything that originates from one of these providers, seeing as it is so easy to churn up your own little spam factory using EC2 or Rackspace for very little cost.

Even if you take these precautions, however, you'll run into a situation where someone gets a hold of your domain name and drags it through the mud. They'll send out thousands of emails to the internet in your name--or rather, in your domain's name--and because of the insecurity of email, your domain will get added to someone's blacklist after a thousand occurrences of [email protected] hit the sysadmin's inbox. There's nothing you can do about it, either.

Or you can decide to run a cloud app and use a remote mail server. But some jokers will get one look at the originator being EC2 and will say, "Nope, sorry. Denied." They don't care about the legitimacy of your organization, only the origin of the email.

Email is an antiquated technology that has been rushed into mass usage before we really were able to think of a better protocol. As a protocol, it's terrible....and yet we're stuck with it, for backwards compatibility reasons. You cannot possibly avoid the spam filter. 95% of the email on the internet is junk mail, and never even reaches the intended recipient. Just absorb the enormity of that statistic for a moment, and pull your ideas back to reality. Many of the spam-prevention techniques being used today are unnecessarily aggressive, and create a great many 'false positives'. You can shoot for, say 80% of your email being sent, but what it really comes down to is this: As soon as the email has been fired off, it's completely out of your control. You can only take responsibility for so much.

Shawn Grigson
Agreed, emailing past spam filters is a tough art that many of us try and work with. You can look at SPF and other Mail Server authentication schemes as well if you run your own mail server, as many of those will go past a Spam Filter.
tekiegreg
"Spam filters will probably be okay with this, since the from email address of *@registeredsite.com resolves to your server." ------ Not necessarily. If, for the sake of example, you use Google mail for your domain, then the MX record(s) for the domain do not resolve to the IP of the server where the email originated, instead they resolve to Google's mail servers. That looks spammy. To get around that, you can use Google's SMTP (or your mail provider) to have the messages originate from Google, achieving a correct Reverse-DNS lookup, and looking significantly less spammy.
Adam Tuttle
Of course, using external SMTP usually comes with its own limitations. Google defines theirs here: http://mail.google.com/support/bin/answer.py?answer=13287
Adam Tuttle
@Adam Tuttle - +1 for reverse DNS. Making sure the DNS records for your domain properly establish a reverse DNS goes a long, long way to keeping your domain's email out of the spam bin if you're a legit emailer. And if you're a spammer, it makes you that much easier to black-hole to boot.
Eric Kolb
@Adam: I hadn't considered the Google angle. Great comment.
Shawn Grigson
Turns out that bpanulla's link suggests that the style tag be placed within the <body>, not the <head> tags. Interesting. I'll amend my example accordingly.
Shawn Grigson
+1  A: 

I would start by finding an HTML template email that you like. Then you put it in the tags with the type set to html as mentioned above. You might want to consider doing the multipart email to handle plaintext (and blackberry) users.

Jas Panesar
+1  A: 

Might wanna check out this ebook from mailchimp. Email apps render HTML in some crazy ways, so be prepared to use tables for layout. http://downloads.mailchimp.com/guides/Monkey_Style_Email_Jitsu.pdf

JKirchartz
+2  A: 

And I would add to this all that you can check whether a mail will be displayed correctly and whether it will get hit by a spamfilter or not by going to a website that is called litmusapp. You can send your test newsletter to one of their emailaddresses and then they will give you screenshots of how each newsletter will look like in each type of emailclient. Also it checks the newsletter against a few popular spamblockers and gives you advice on what to change.

Steven
+1  A: 

I subscribe to the Campaign Monitor Newsletter & they also have a list of very useful articles here: http://www.campaignmonitor.com/resources/

Pragnesh Vaghela