Archive

Archive for March 31, 2011

AmazonSES API wrapper for Railo/ACF

March 31, 2011 9 comments

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.

AmazonSES: Sending your verification email with Railo

March 31, 2011 2 comments

I have a client that I am in the process hooking into Amazon’s Simple Email Service for handling their member and mass e-mails.  Originally I was trying to do this through their Google Apps e-mail but it has been problematic at best because Google keeps disabling their mailing account.  Needless to say, it is not fitting their requirements.

My buddy Todd suggested moving them to AmazonSES and after looking their product it looks to be a good fit for my client.  I have not found a wrapper for their API for ACF/Railo so I am working on getting a wrapper together that I will release as well as document the steps you need to take to get this working on your own installation.

The first step in getting AmazonSES working is sending the verification email to your account.  Amazon’s web site has a script written in perl you can use to send it, but I did not feel like installing extra software on my server just to get the account setup.  Instead I decided to do it through the Java API on Railo.   I did not find any examples of how to do it, so I just had to figure it out myself.  Hopefully it will help someone else out.

<cfscript> 
 awsCredentials = createObject("java", "java.io.File").init("#expandpath('.')#/AwsCredentials.properties");
 credentials = createObject("java", "com.amazonaws.auth.PropertiesCredentials").init(awsCredentials);
 email = createObject("java", "com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient").init(credentials);
 verifyRequest = createObject("java", "com.amazonaws.services.simpleemail.model.VerifyEmailAddressRequest").withEmailAddress("your@email.com");
 email.verifyEmailAddress(verifyRequest);
</cfscript>

In the verifyRequest assignment the your@email.com with your personal email address and a verification will be sent to your email.  After activation you can start sending out emails from your verified address. I will put a more detailed installation guide later this evening.

Update: You can also read about the completed AmazonSES component.

Follow

Get every new post delivered to your Inbox.

Join 364 other followers