What would be the best way to go about making ActionMailer send mail via Amazon SES in Rails 3?
Edit:
This is now a gem:
gem install amazon-ses-mailer
What would be the best way to go about making ActionMailer send mail via Amazon SES in Rails 3?
Edit:
This is now a gem:
gem install amazon-ses-mailer
After poking around a bit I ended up just making a simple class to do this.
https://github.com/abronte/Amazon-SES-Mailer
In rails, you can get the encoded email message:
For TLS SSL setup [Recommended by Amazon SES]
You don't need gem for this thing.
smtp is defualt way of sending email in rails but you can add this line to explicitly define in config/application.rb file
In config/application.rb or you can specify in certain environment file
The Amazon SES SMTP HOSTNAME is specific for every region, so you that name which you are in, following are hostnames wrt regions.
StackOverFlow | Amazon-getting-started-send-using-smtp
I created a simple Rails / SES API gem that uses Signature v4 to sign the request. This is best used for transactional emails such as contact us, user registration, etc.
Rails SES API integration gem
Please feel free to improve on it & contribute.
SES just was released into beta today, so I doubt that there is a ready-to-go gem (at least, not that I've seen). You could write a custom module based upon their developer documents:
I use the following gem:
https://github.com/aws/aws-sdk-rails
It pulls in the standard aws-sdk, plus allows to set ActionMailer to use AWS SES. Example:
Setting up Rails 3.2 for sending emails using Amazon's Simple Email Service (SES) is easy. You do not require any additional gem or monkey patching to make it work.
SES supports both STARTTLS over SMTP as well as TLS/SSL. The following demonstrates how to set up Rails for STARTTLS with SES.
Prerequisites
If you are running rails Mac OS X, you may need to configure OpenSSL for Ruby correctly before you can use STARTTLS. If you are using Ruby 1.9.3 and RVM, here is one way to do this:
If you do not do this, there is a possibility that Ruby will segfault when you try to send an email.
Make sure you have verified your sender email address with AWS. You can only send emails with a verified email address as the sender. Go to the "Verified Senders" option on the left menu in AWS console for SES.
Make sure you have the AWS SMTP user name and password for authentication. Go to the "SMTP Settings" option on the left menu in AWS console for SES to set this up. You will first be prompted to create an IAM user (default: ses-smtp-user) and then you will be shown the SMTP user and password, which look like usual AWS key and secret. Note that the IAM user, i.e., ses-smtp-user is not the SMTP user that you will be using for authentication.
Configuring Rails
In config/environments/development.rb and config/environments/production.rb, add the following:
Sending an email
This is it. Now you can go ahead and create a mailer and start sending emails for fun and profit!
Create a sample mailer
In app/mailer/user_mailer.rb:
In views/user_mailer/test.erb:
Now, launch the console and shoot off a test email: