Send Emails with Amazon SES, Part 1: Simple SES Template

Shivanjali Nimbalkar
IntelliconnectQ Engineering
2 min readMay 28, 2021

Amazon Simple Email Service (SES) is a cost-effective email service built on the reliable and scalable infrastructure that Amazon.com developed to serve its own customer base. With Amazon SES, you can send transactional email, marketing messages, or any other type of high-quality content to your customers.

Pre-requisites :

  1. Access to AWS SES Console
  2. Verified Source Email to Send Email From Know More
  3. AWS CLI Know More

There are two ways for creating Templates and Sending Emails :

  • AWS CLI
  • AWS SDK

Using AWS CLI :

  • Viewing a list of email templates : aws ses list-templates
  • Viewing the contents of a specific email template : aws ses get-template --template-name MyTemplate
  • Create : aws ses create-template --cli-input-json file://mytemplate.json
  • Update : aws ses update-template --cli-input-json file://path/to/update_template.json
  • Delete : aws ses delete-template --template-name MyTemplate

Following is the content for mytemplate.json :

(Make sure your CLI version is up to date to execute the above commands)

  • To Send Email using CLI : aws ses send-templated-email --cli-input-json file://myemail.json
  • Following is the content for myemail.json :

I above code, replace Verified-Email-ID with your Source Email Id verified as described here

Using AWS SDK

Here I have used NodeJS aws-sdk to Create, Update, Delete Email Templates and Send Emails.

Firstly install aws-sdk : npm i aws-sdk

Then, let’s create the email template, create a file named createSESTemplateWithVariables.js and following content to it :

Now, execute this code by this command :

node createSESTemplateWithVariables.js

After executing, you will get a response as shown below, and a template will be created in the specified region:

Similarly for updating or deleting the template, you can refer here.

Now, let’s send this Email template. For this, create a file named send_mail_using_ses_node.js and following content to it :

When we execute this code using, node send_mail_using_ses_node.js , email will be sent to specified destinations and response will be as shown below :

Thank you for reading!

For more information refer to our git repository over here.

References :

--

--