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


Create your own user feedback survey