AmazonSES API wrapper for Railo/ACF


As I alluded to this morning, I have been working on a wrapper API for the Amazon SES service.  It is not yet completed, but it is functional enough to get you sending some emails through the gateway. Currently it will allow you to get a listing of emails addresses verified with Amazon Web Services, create a verification email so that you can verify your email address with AWS as well as actually sending an email through Amazon SES.

Integration with Railo (and presumably ACF) is straight forward.  First, download the Java SDK for AWS.  Extract the file and in the ./lib folder you will find the jar file we will need to move into your classpath for Railo/ACF.  At the time of this writing the file is aws-java-sdk-1.1.8.jar. I generally use the Viviotech installer which places Railo in /opt/railo on Linux and I copied the SDK jar to /opt/railo/lib. Restart Railo so all the jars will be reloaded giving us access to the API.  I do not have access to an ACF server so your mileage here may vary.

The server configuration done, now you just need to go to AWS and get your access key and secret key.  These are required to authenticate your connection to Amazon and should be stored in the AwsCredentials.properties file.  You obviously want to keep this file protected so I would suggest storing outside of your web root or create some rules on your web server to ensure no one can view the file.  Once you have this setup it is time to send some emails!

Sending an email is extremely easy to do.  First create a new instance of the amazonSES component and then invoke the sendMail method passing in the required parameters (from, to, subject and the message body).  If you have not already verified your address with Amazon, the script will create a new verification email and send it to your email address and then throw an error letting you know you need to check your email for the verification.  If you have already verified your email address it will just send the email out.

That is about all I have for tonight.  As noted above, I have only tested this on Railo, I do not have an ACF box to verify against.  It will probably need to be modified to handle multiple message recipients (I have not tested this yet). I plan on working on some new features this weekend if I have a little free time.

I have included a simple application you can use to test the installation.  If you have any questions, problems or suggestions, please let me know.

Update: I have created a RIAForge project for the AmazonSES API wrapper.

Update 2: I have linked to the older version of the AWS API on my forum and you can download the file here if you are having issues.

About these ads

About Robert Zehnder

Web application developer specializing in ColdFusion/Railo and Open Source development.

Posted on March 31, 2011, in AmazonWS, ColdFusion, Railo and tagged , , . Bookmark the permalink. 9 Comments.

  1. Any experience using CF with SES vs SendGrid ?

    • Honestly, I haven’t looked at it. The main reason I went with Amazon Simple Email Service for my client is they also plan on hooking into other AWS services like the S3 storage in the future and we can consolidate their billing.

      From a pricing standpoint, I like being charged for usage only and not having to worry about a monthly fee.

  2. Good points. I just did a quick cost analysis and SES is much cheaper than SendGrid ($0.0001 vs $0.001 per email). Plus, no monthly mins. You get more features w/ SendGrid but if you don’t need them, SES might be the better choice.

    I’ll keep this discussion in mind next time I have prj that needs this functionality. And now, there’s a great CFC to use :)

  3. This is golden! Thanks for putting this together. I had to make a few minor tweaks to clear up some errors on ACF9, but after that works great!

  4. Thanks for the creating this, it saved me a bunch of time. On a side note, I had to download some more jar files here http://hc.apache.org/index.html (placed them in my railo libs folder), because the new implementation of the java aws sdk requires a newer version of the Apache HttpClient 4 http://aws.amazon.com/releasenotes/9726474311325478.

    • I have an older version of the Java AWS API running on my production servers so I haven’t run into this issue yet. I appreciate the update though, others will be running into this issue.

  5. I have linked to the AWS API I used while developing the component. You can find the link above in Update 2.

  1. Pingback: AmazonSES: Sending your verification email with Railo « KISDigital Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 866 other followers

%d bloggers like this: