Doug's Resume
OO Lexicon
Chat with Doug!
Recent Entries
You may also be interested in...

heaters
hotels boeken in 7 sec
Engagement Rings
Online Dating Australia




SURF'S UP!
You:
Your Web Site:
<< May, 2008 >>
SMTWTFS
123
45678910
11121314151617
18192021222324
25262728293031
Search Blog

ColdFusion Jobs
Recent Comments
Re: The Perfect Alternative to Gas Powered Vehicles (by Thomas Messier at 5/09 12:47 PM)
Re: Promoting Family Unity: Lowering Your Utility Bills! (by Fernando Lopez at 5/07 10:12 PM)
Re: Why I Hate ORMs (a solicited rant) (by Richard at 5/06 10:56 AM)
Re: Why I Hate ORMs (a solicited rant) (by dougboude at 5/06 10:27 AM)
Re: Why I Hate ORMs (a solicited rant) (by Richard at 5/06 6:50 AM)
Re: Why I Hate ORMs (a solicited rant) (by Sean Corfield at 5/06 1:40 AM)
Re: Why I Hate ORMs (a solicited rant) (by Steve Bryant at 5/05 5:07 PM)
Re: Why I Hate ORMs (a solicited rant) (by dougboude at 5/05 4:36 PM)
Re: Why I Hate ORMs (a solicited rant) (by Mark Mandel at 5/05 3:52 PM)
Re: Why I Hate ORMs (a solicited rant) (by dougboude at 5/05 3:42 PM)
Categories
Archives
Photo Albums
Funnies (5)
Family (3)
RSS
Reciprocal Links

Powered by
BlogCFM v1.11

04 February 2008
Using Google as your CF Mail Server
Ah, sounds like a no brainer, right? Why even do a blog post on such a thing, right? Because Google requires that an SMTP connection be encrypted...something that CFMX7 just doesn't do all by its lonesome. I need to vent a little, so here's my story followed by some useful info....

It's extremely late on a Sunday night and you're in the final final stages of a site migration for a client. Their "under construction" sign says that everything will be back online and kosher at 7 am Monday morning, so you're addressing one of the last things on your list: setting up the client's mail server.

It made it to the end of the list because of the fact that they're using a third party to relay their mail: Google. Now everybody knows Google's reputation for being logical and actually making sense most of the time, so how hard can it be to make sure that Coldfusion is pointing to the client's Google SMTP, especially when the client said it was a piece of cake when they set it up the first time? You figure out later that the person who told you that wasn't actually the person who set it up to begin with, as the passing time turns into a couple of hours and you still haven't sent a successful email.

(Here comes the venting part I mentioned...) You know what chaps my hide, grinds my gears, gets my goat (I wonder where that one evolved from), et al? It's the same thing that gets my goat most of the time, the incredibly cryptic nature of some things that ought to be simple and all of the other people out there on the net who managed to get it to work but insist on only sharing yet more cryptic or worse yet, elusive, information on how they did it (if they share any of the "hows" at all!). I want to share with you my journey, at 2 am on a Sunday night, to learning how to set up a secure tunnel to an smtp server for the purpose of using Google's smtp server for sending email. I want to do this, ALL IN ONE BLOG POST, just in case anybody else out there EVER finds themselves in the position I was...I wouldn't wish such a frustrating, elusive game of Clue on any other person.

CUTTIN' TO THE CHASE, if you're trying to use Google's smtp server to send mail and you're seeing errors like this one
coldfusion email error log

in your mail log file, it's telling you that Google requires you to authenticate to its smtp server via an SSL connection, and any Coldfusion version below 8 (I read a short post saying that version 8 could handle such things, but the poster FAILED to give any other clues as to how to implement it...sheesh) can't do that all by its lonesome. So, we need an intercessor, a little service running on the web server that will intercept requests to ports internally then reroute the request to an outward-facing port using a secure connection. That intercessor is called 'STunnel' (though there were a couple of other equal products I came across). In a numbered list then, here are the steps a body needs to do in order to make it work:

1. Make sure you have a Google email account.
My client is signed up to use Google Apps, which includes an email server. Here's a starter link for you: https://www.google.com/a/help/intl/en/admins/editions.html

2. Make sure you know the username and password for the Google email account

3. Download and install a program called STUNNEL (latest windows exe can be found on this page: http://www.stunnel.org/download/binaries.html)

4. Edit Stunnel's configuration file (the default config file is in the stunnel directory, and is called "stunnel.conf").

5. Empty out the config file and paste  in the following values:
client = yes
debug = debug
[pop3s]
accept = 127.0.0.1:1109
connect = pop.gmail.com:995

[smtps]
accept = 127.0.0.1:259
connect = smtp.gmail.com:465


6. Go into your CF Administrator, to the mail settings, and enter the appropriate values according to the illustration and your own username and password

coldfusion mail server settings

(note: 127.0.0.1 is not a placeholder value in this blog post: use that value! Also, notice the port number used, 259; it's the same number in the stunnel.conf file for accepting SMTP mail.)

7. Go to the stunnel directory under Programs and choose to install it as a service, then run it as a service.

8. Go to your services list and make sure stunnel is running.

9. Just for fun, restart the CF service

10. Execute a template you made that has a cfmail tag set up similar to the following:

    <CFMAIL
            TO="dougboude@gmail.com"
            FROM="admin@myclient.com"
            SUBJECT="test email from server"
            TYPE="HTML">
    testing
    </CFMAIL>

11. Log in to your google mail and look in your sent items folder. The email you sent should appear there tout suite. (Google apps allows you to point a subdomain to their email server...my client's is similar to "mailbox.clientdomain.com", fyi)

12. if you don't see the email in the sent items folder, check CF's mail log and make sure it didn't generate a STARTTLS error

If you do all of this and it still doesn't work, I'm afraid I have no more information for you. BUT, if you run into additional issues and DO manage to fix them, please post that info back to the comments area of this post for the benefit of others!

Okay, I feel better now. Being forced to invest SO much time and energy, at 2 am, and then finding nothing but a few nearly useless clues here and there to go on can really drain a person emotionally, ya know? :)

Doug out.



Posted by dougboude at 12:13 PM | PRINT THIS POST! |Link | 3 comments
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

Re: Using Google as your CF Mail Server
Definitely saving this post for future reference. Awesome.
Posted by Ben Nadel on February 4, 2008 at 12:46 PM

Re: Using Google as your CF Mail Server
In CF8 when configuring the mail settings there is an option:

Enable SSL socket connections to mail server
Select this check box to enable SSL encryption on the connections to the mail server.

Check that and you can use GMail. I've done it in the past but now use spoolmail by Ray Camden.
Posted by Sam Farmer on February 4, 2008 at 12:50 PM

Re: Using Google as your CF Mail Server
I ran into this with 7 as well. The only thing I was able to come up with was jscape. I have a post on it here:
http://www.roktech.net/devblog/index.cfm/2006/10/24/Cfmail-Google-Tools-For-Your-Domain-and-SPAM

Lucky for me, 8 fixes all of that....

Jason
Posted by jason on February 4, 2008 at 5:14 PM

Name:   Required
Email:   Required your email address will not be publicly displayed.

Want to receive notifications when new comments are added? Login/Register for an account.

Time to take the Turing Test!!!

What letter comes three place(s) before the letter L?
Type your answer exactly three time(s) in the designated box.

Type in the answer to the question you see above:

Your comment:

Sorry, no HTML allowed!