Simple guide to setting up Amazon SES in Ruby on Rails using SMTP.
Recently started having issues with my existing email provider, where I’d been using their SMTP server to send transactional emails.
Then I thought, “hey, why don’t I use Amazon SES?”, which is what I already use for sending my newsletter.
This post is a guide for how to get setup with sending email with ActionMailer in Ruby on Rails using Amazon SES’s SMTP server.
Bonus: You will not have to install Amazon’s AWS SDK for Ruby!
What is Amazon SES?
Amazon SES is Amazon’s Simple Email Service. It is a relatively cheap web service that is highly scalable and has good deliverability. It can be used for sending transactional emails (my use-case), marketing and newsletters, etc.
I assume you already have a Ruby on Rails app and you know how to use ActionMailer. This guide is for replacing the SMTP server with Amazon SES so everything else should already be in place.
As such, most of this guide pertains to setting things up inside Amazon’s Developer Console.
The only thing that has to change on the Rails side is your config file (e.g. /app_root/config/environments/production.rb).
Setting up Amazon SES
1. Go to https://aws.amazon.com/console/ and login.
2. Search for “ses” (or similar) in the search bar and click on the result.
3. Go to the “Verified Identities” tab on the left-side navigation, and create 2 email addresses (one for the sender, one for the receiver) by clicking the button that says “Create Identity”.
4. After creating the email identities, you’ll receive a confirmation link at each email address. Click them to verify.
5. Create an identity for the domain you want to send emails from (e.g. for me that’s deeplearningcourses.com). This takes a bit more work as you’ll need to update your DNS configuration.
6. Go to your “Account dashboard” and then click the button that says “Create SMTP credentials”. This will give you a username (you get to pick) and password. Create and download those, and store them safely.
7. Using your credentials, you can now update your production.rb (or development.rb) file with the SMTP credentials you just created.