Use of Amazon SES in Rails App to Send emails

5 April 2016 by Meenakshi Naik No comments

What is Amazon SES?

Amazon SES is an email platform that provides an easy, cost-effective way to send and receive email using your own email addresses and domains.

Sending Email with Amazon SES using SMTP

You can use Simple Mail Transfer Protocol(SMTP) to send emails by using Amazon SES. You need an Amazon SES SMTP username and password to access the Amazon SES SMTP interface.

To create SMTP credentials:

1. Sign into the AWS Management Console and open the Amazon SES console at https://console.aws.amazon.com/ses.

2. In the navigation pane, click SMTP Settings.

3. In the content pane, click Create My SMTP Credentials.

smtp_settings

4. In the Create User for SMTP dialog box, you will see that an SMTP username has been filled in for you. You can accept this suggested username or enter a different one. To proceed, click Create

create_smtp_user

5. Click on Show User SMTP Credentials. Your SMTP credentials will be displayed on the screen; copy them and store them in a safe place. You can also click Download Credentials to download a file that contains your credentials.

After creating your SMTP credentials, open the Verified Senders/Email Addresses screen. Before you can send an email using Amazon SES, you have to own an address or addresses which are going to be used as senders across the SES SMTP mail servers.

verify_a_new_email_address

Configure mailer with SMTP with rails app:

Add the following code in config/environments/*.rb

Then add following code in mailers/ses_mailer.rb

Note: If your account is in Amazon SES sandbox, then you must also verify the email address of every recipient. For moving out of the sandbox, see Moving Out of the Amazon SES Sandbox.

View: view/ses_mailer/welcome.html.erb

Call Mailer:

You can track your email sending statistics on Sending Statistics of Amazon Console.

Sending emails using aws-ses gem:

1. Add aws-ses to the gem file – https://github.com/drewblas/aws-ses

2. Extend ActionMailer in config/initializers/your_config_file.rb, where config_file.rb is the name of the file which contains initialization routines for ses gem:

3. Then set the delivery method in `config/environments/*.rb` as appropriate:

You are now ready to send emails from rails app through Amazon SES. Just make sure you have verified email addresses through which you are going to send the emails and you are out of Amazon SES sandbox. Happy Mailing!!

Meenakshi Naik

Follow me on Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Blog

Get access to proven marketing ideas, latest trends and best practices.

Next up home

Contact

Lets build cool stuff

Share your contact information & we will get in touch!

I want (Tell us more about your dream project)