Getting Started with AWS SES

Using AWS SES is quite simple. In this article I will try to cover how to send email through SES (using sandbox) and how to create configuration set. Some tips as well to get out of sandbox and using SES in real world scenarios.

Usama Yousuf
Jun 27 · 7 min read
Photo by Davide Baraldi on Unsplash

Like many other awesome goodies from amazon, Simple Email Service is one of the very popular and highly scale-able service, used by thousands of businesses and developers across the globe. Some of the notable businesses are HBO, Siemens, Careem etc. Recently got a chance to work on it and I found it very convenient and easy to setup. The combined power of other amazon services (like SNS, SQS, Lambda) with AWS SES makes it work like a charm and fit to your business needs as required. Moreover its quite cheap as well, $0.10 for every 1,000 emails. Click here to see more on pricing.

For people who still don’t know what SES shiz is, here’s how Amazon describes it:

Read more about it here.

That’s enough of introduction, now lets get started. I will try to demonstrate the following:

  1. Add email recipients and verify them. In sandbox we have to verify all recipients and senders.
  2. Send email to verified recipients via Lambda function using AWS nodejs sdk.
  3. Create a configuration set to publish email sending events — like bounces, complaints, deliveries, sent emails, and rejected emails — to a particular email address via AWS SNS.
  4. Tips about how to get out of sandbox

For this you obviously need an AWS account. Sign in to console and goto SES homepage.


1. Add Email Recipients:

On SES console home, from Identity Management in left bar, select “Email Addresses” and then click on the big blue button saying “Verify a new Email Address”. Enter your email address in the popup that appears.

Now click on the “Verify This Email Address” button. You will be prompted with a message, check your mailbox, there would be a message waiting for your attention from AWS. Click on the link inside message body of that email to verify your address as a recipient.

Popup after clicking on “Verify This Email Address” button

Before you confirm your email address, check the ‘Verification Status’ in console.

Verification Status “pending”

After you confirm, the status would be changed to confirm. You might need to reload.

Verification Status changed to “Verified”

Now we can use this email as a sender or recipient. Try adding one more email address similarly. We will require them further to send and receive emails.

2. Send Email Through Lambda and SES:

Goto AWS Lambda console and click on “Create Function” button.
Now select “Author from scratch”, give your lambda function a name, select Node.js 10.x as Runtime and in Role section, select “Create a new role with basic lambda permissions”.
Click on the orange button at bottom right to create your function. You will be redirected to the lambda function editor/designer page.

Creating a lambda function

Before we start coding, we need to allow our lambda function to access AWS SES to send emails, so goto IAM console and click on ‘Roles’.

In IAM Console goto ‘Roles’ page.

Find your AWS Lambda role from the list and click it. I named my lambda ‘medium-send-email-via-ses’ so my role name was “medium-send-email-via-ses-role-xe66ua7m”.

In the role summary page, click on “Attach Policies” button under permissions tab.

Click on attach policies button in role summary page

By default lambda execution role has only access to cloudwatch logs, if we need to use any other services inside it or link our lambda function to other amazon resources, we first have to explicitly grant permissions to the lambda execution role.

After clicking on “Attach Policies” button, search for “AWS SES” in policies and attach “Full access” to it. See image below.

Select AmazonSESFullAccess policy and click on ‘Attach policy’ button

Now go back to your lambda console, paste the code below and click save. This is a simple Node.js program that uses aws sdk to send email via SES. Make sure to change <sender_email> and <recipient_email> to the email addresses that you just verified in first step.

Before testing our function, we will first jump to step 3 — Creating a configuration set that sends bounces, complaints, deliveries, sent emails, and rejected emails to a particular email address via AWS SNS. You can safely skip this step if you want to work inside sandbox environment or you don’t feel the need of it.

A picture from my previous workplace — This image has nothing to do with AWS SES. Just added to avoid being too textual.

3. Creating a Configuration Set:

In SES management console, click on ‘Configuration Sets’ from left sidebar. Read the description mentioned on the page to get a better understanding and then click on ‘Create Configuration Set’. Give it a name and click create.

Configuration set with name ‘my-ses-config-set’ created successfully

Click to edit it. In Event destinations tab, add a destination from the dropdown and select SNS.

Select SNS from the dropdown

Select the check boxes according to your need. For demo purposes I have selected Delivery, bounce and complaint. In the topic dropdown select “Create a new Topic”.

Create SNS topic

Now give SNS topic a suitable name and click create. We will then create an email subscription to this SNS topic which will eventually send all the bounces, complaints and delivery notifications via email to the subscribed address.

Create New Topic

Goto SNS console and click on the topic we just created and then click on “Create Subscription”. Select “Email” in protocol and enter your email address. You have to confirm your email for SNS as well just like we did in first step. Make sure to enter an email address other than the ones you have already verified for SES.

Create an email subscription for your SNS topic to get bounces, delivery etc alerts

Go back to Lambda console and open the function we created previously. To test the function click on “test” button on top right corner of lambda editor. Search the keyword “SNS” in “Event Template” and select “Amazon SNS topic Notification” and click “Create” button.

Creating a sample event template to call lambda function

After creating sample event, click on ‘Test’ button again to test your lambda function. If everything works fine, you will receive an email on the address you declared in your function. In case of any error you can watch the logs in cloudwatch.

Click on Test button

Thats it ! We just send an email via SES. So simple and easy (apart from the configuration set part 😛). Also we got the ‘Mail Delivery’ alert, thanks to SES configuration set that we configured.

The Email via SES flow works like following:

Email received via SES

& the Configuration Set flow works like:

Bounces, complaints & delivery event type alert received via SNS topic

But this was Sandbox and obviously if need to use it practically, we cant do it this way (explicitly verifying every email address first, plus in sandbox we can only send 200 emails a day) and we have to get out of sandbox environment.

4. Tips To Get Out of Sandbox Environment:

We have to request a limit increase to use AWS SES practically, like for marketing, email alerts, push notifications to subscribers etc. If you state your use case clearly, chances are that you will get your limit increase approved within a week. But a few things should be taken care of before applying for it, so that you give them no chance to reject your request:

  1. Make sure you have setup your Configuration set and you have a plan for your bounces, rejects and complaints etc. If not, AWS representative will reject your request and will ask you to setup configuration set first.
  2. Fill all fields, even the optional ones (like mail type, website url etc)
  3. Never ever select “NO” when asked My email-sending complies with the AWS Service Terms and AUP” :p
  4. Always select “YES” when asked “I have a process to handle bounces and complaints”
  5. In Case description, mention your use case clearly and try to justify the limit you are asking for.
  6. Submit your request and avoid spamming :D !!!