Deliver Email With Amazon SES In A Rails app

Add the gem:

gem "aws-ses", "~> 0.6.0", :require => 'aws/ses'

to Gemfile and run bundle. Add:

ActionMailer::Base.add_delivery_method :ses, AWS::SES::Base,
  access_key_id: ENV['AMAZON_ACCESS_KEY'],
  secret_access_key: ENV['AMAZON_SECRET_KEY']

in config/initializers/amazon_ses.rb. Configure deliver method in config/environments/production.rb:

config.action_mailer.delivery_method = :ses

Other email settings are:

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

After you signup for SES, you must request daily email limit according to your needs. Otherwise, you will not be able to send any emails.

Request Rate Increase

You can use the mailer to deliver the email in the background:

PurchaseNotifierMailer.send_purchase_confirmation_email(@user).deliver_later

ActionMailer will now be able to use SES to send emails.


Related Articles


Software Compatibility Best Practices

I spoke to some of the most talented and experienced software developers. I have created a guide that is filled with valuable insights and actionable ideas to boost developer productivity.

You will gain a better understanding of what's working well for other developers and how they address the software compatibility problems.

Get the Guide Now