Send email using Amazon SES (NodeJS)

In this tutorial, we are going to send emails using Amazon SES.

Note: In my next tutorial, I am going to show how to monitor email using AWS Lambda.


  • Nodejs
  • AWS account
  • Code editor (VS Code)

Make sure you have all them on your computer.

What is Amazon SES?

Amazon Simple Email Service (Amazon SES) is a cloud-based email sending service. This is a pay-as-you-go service based on the volume of emails sent and received. There are no subscriptions, no contract negotiations, and no minimum charges. Using Amazon SES you can send transactional and mass emails. It provides SMTP interface, AWS SDKs for seamless integration with our apps. For more details read this.

Create a Project

Open your terminal and create a project directory.

mkdir send-and-monitor-email && cd send-and-monitor-email

after that

npm init

To send email¸ we need aws-sdk package and we want to separate our credentials for that we need dotenvpackage.

npm i aws-sdk dotenv

Now we need .envfile to separate our credentials and we also need sendEmail.jsfor writing email sending logic.

touch sendEmail.js .env

Open .env file on your favorite code editor and add the credential of your AWS account.


Send Email

We are done with the project setup. Now we have to log in to the AWS account to configure SES for sending emails. Let’s login from here.

After login successfully, click on services nav-item then search for ses and go to the Amazon SES home page. Now click on Email Address tab and verify the email that you want to use as a source. If your SES in Sandbox mode, You have verified both source and destination email. If you enable SES to production mode then you don't need to verify destination email only source email.

SES email address verification screen
SES email address verification screen

Now our email verification step is done. Let’s start writing our email sending logic on sendEmai.js file.

ToAddresses: This param takes an array of email addresses that you want to send your mail to.

Body.Html.Data: HTML message template. All the styles have to be inline

Body.Subject.Data: Subject of the email

Source: Email address of the sender

Now add the following code to your sendEmail.js file and replace the Source and Destination.ToAddress with your verified email address. Then run the following command.

node sendEmail.js

If you have done everything correctly you should get a response like the below image on your terminal. Or if you get any error try on your own to solve by googling error message.

Successful email sending response
Successful email sending response

This is TEXT/HTML email. We can also send emails using templates. I am not cover it here. If you are interested, read this.

Thank you for reading till the end. I appreciate your time and energy. Please stay tuned for my next article.

Developer, Book lover.