Coldfusion 9 mail issues using Amazon Simple Email Service (SES)

Copy link to clipboard
Copied
I've been having an intermittent issue sending out emails from our Coldfusion 9 application. We have Coldfusion 9 Enterprise on a Windows 2008 Server that is running 5 different Coldfusion instances. In our case, each of the instances are connected to the same Amazon SES service as its' mail server. We are using authentication and TLS. We send out between 2,000 and 15,000 emails per day typically and I'm getting intermittent errors as shown on the mail.log:
"Error","scheduler-4","04/21/14","07:54:27",,"javax.mail.MessagingException: Unknown SMTP host: email-smtp.us-west-2.amazonaws.com; nested exception is: | java.net.UnknownHostException: email-smtp.us-west-2.amazonaws.com" |
"Error","scheduler-0","04/21/14","08:01:55",,"javax.mail.MessagingException: Unknown SMTP host: email-smtp.us-west-2.amazonaws.com; nested exception is: | java.net.UnknownHostException: email-smtp.us-west-2.amazonaws.com" |
In these cases, the emails are sent to the Undeliverable folder and are never sent. If I subsequently place them back in the Spool folder, then they go out without fail.
This is happening across all 5 CF instances and (depending upon volume) occurs almost daily or up to 10 times per day (per instance).
Further examination of the exception.log shows a more detailed version of the error.
"Error","scheduler-0","04/21/14","08:01:55",,"javax.mail.MessagingException: Unknown SMTP host: email-smtp.us-west-2.amazonaws.com; nested exception is: | java.net.UnknownHostException: email-smtp.us-west-2.amazonaws.com" |
javax.mail.MessagingException: Unknown SMTP host: email-smtp.us-west-2.amazonaws.com;
nested exception is:
java.net.UnknownHostException: email-smtp.us-west-2.amazonaws.com | |
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1543) | |
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:453) | |
at javax.mail.Service.connect(Service.java:291) | |
at coldfusion.mail.MailSpooler.getConnection(MailSpooler.java:1244) | |
at coldfusion.mail.MailSpooler.deliver(MailSpooler.java:987) | |
at coldfusion.mail.MailSpooler.sendMail(MailSpooler.java:905) | |
at coldfusion.mail.MailSpooler.deliverFast(MailSpooler.java:1364) | |
at coldfusion.mail.MailSpooler.run(MailSpooler.java:1274) | |
at coldfusion.scheduling.ThreadPool.run(ThreadPool.java:211) | |
at coldfusion.scheduling.WorkerThread.run(WorkerThread.java:71) |
Caused by: java.net.UnknownHostException: email-smtp.us-west-2.amazonaws.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195) | |
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) | |
at java.net.Socket.connect(Socket.java:529) | |
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:265) | |
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:227) | |
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1511) | |
... 9 more |
In an effort to reduce the frequency of this error and/or eliminate it, I've changed my CFAdmin settings to uncheck the "" option (based on this article http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-issues.html) but that didn't seen to make a difference. I've additionally added a backup email server using a secondary zone from Amazon SES and that has reduced the frequency of the error (perhaps simply due to having redundancies) but the exceptions are still occuring.
I don't know if this is a Coldfusion issue or if it is an Amazon SES issue. Does anyone have any suggestions and/or insight here?
Copy link to clipboard
Copied
Sounds like a nameserver (DNS) issue since the error is that the SMTP host itself cannot be found. Do you have the option to change your name server? if you are prepared to live with the problem you could just copy the files from the undeliverable folder back to spool on a scheduled task - we've done this before when we had unresolvable issues with some third-party SMTP servers.

Copy link to clipboard
Copied
Tribule, thanks for the response but I just have a hard time believing that the DNS would fail that frequently (especially with Amazon Web Services). I believe that it has to do the with Load Balancing nature of the Amazon SES and/or the JVM trying to maintain their connection.
I restarted the CF services on each instance last night and haven't (knock on wood) had any emails fall back to the secondary email server and therefore haven't had any mail exceptions in the past 16 hours. I'm thinking that perhaps my settings changes (unchecking Maintain Connection to Mail Server) have corrected the issue but required a CF restart to take effect.
I'm crossing my fingers but hopefully that is the answer.
Copy link to clipboard
Copied
Yes, from reading the documentation on the SES blog it seems one must not maintain connections to the endpoint. Let's hope that is it.

Copy link to clipboard
Copied
Unfortunately, this happened again last night on 2 of the instances. One was at 8:25pm and the other at 8:33pm. The backup email server sent approximately 20 emails before that one failed as follows:
javax.mail.MessagingException: Unknown SMTP host: email-smtp.us-west-2.amazonaws.com; nested exception is: java.net.UnknownHostException: email-smtp.us-west-2.amazonaws.com
In these cases, the "east-1.amazonaws.com" is our primary server so it failed over to 'west-2.amazonaws.com' and that one failed as well. I think I need to look deeper into DNS and/or follow up on Amazon forums as well.
Copy link to clipboard
Copied
Bummer. The error message does imply a DNS type issue ("host not found"). I assume you did not not get any other error apart from that? Perhaps on your server you can change the DNS settings to Google's public DNS (8.8.8.8 and 8.8.4.4) and give that a test for 24 hours just to see if it helps.?
Another long shot: can you specify the IP address of the Amazon server instead of it's canonical name, or do they change IPs all the time?

Copy link to clipboard
Copied
Unfortunately Amazon uses their Elastic Load Balancer so it is changing IP addresses all the time. I tried telnet'ing to it and within 5 minutes, I got 3 different IP's. I'll double check our DNS settings and post back. Thanks again.
Copy link to clipboard
Copied
Perhaps get alternative DNS and test with that for a while? Worth asking Amazon support as well.

Copy link to clipboard
Copied
I updated the DNS servers to use Google and I haven't had an mail exceptions since 08/22/2014 @ 8:30pm. I am still seeing some failover onto the secondary Amazon mail server but that backup mail server is now only sending about 10 emails/day (down from ~50/day using our other DNS settings) out of approximately 10,000 emails sent/day. It appears that you are correct in that this is a DNS issue. It must have something to do with how Amazon uses their ELB with their Simple Email Service and how some DNS servers handle those frequent changes.
Thanks again for your help.
Copy link to clipboard
Copied
Perhaps you need this: http://aws.amazon.com/route53/

