Amazon SES (Simple Email Service) is a popular cloud-based service for sending transactional and marketing emails. It integrates well with all popular programming languages. In this tutorial, I'll explain how to use this email service for sending transactional (or even marketing) email in an Express.js/Node.js project.

Want to integrate AWS SES in Spring Boot project? Follow this tutorial for step-by-step instructions.


To use AWS SES in your project, you must have:

  • An AWS account with full access to SES service (you need to create a support ticket to remove sandbox restrictions)
  • A verified email address or domain name you want to use for sending emails

If you need help, follow these instructions to complete the setup.

👉 Try Amazon SES with EmailOctopus — A low-cost email marketing platform offering high deliverability, customized reports, and the ability to drip email sequences, import contacts and integrate with forms.

Create Node.js project

Let's create a new Node.js project and install all the required dependencies. We will be using the official AWS SDK for JavaScript to call SES email service API.

$ npm init -y
$ npm install express body-parser aws-sdk --save

The -y flag will skip the questionnaire and create a default package.json file project in the root directory.

Sending Emails using AWS SES API

Create ses-client.js file in your project root directory with the following content:


const AWS = require('aws-sdk');

const config = require('./config'); // load configurations file


const ses = new AWS.SES({apiVersion: '2010-12-01'});

const sendEmail = (to, subject, message, from) => {
    const params = {
        Destination: {
            ToAddresses: [to]
        Message: {
            Body: {
                Html: {
                    Charset: 'UTF-8',
                    Data: message
                /* replace Html attribute with the following if you want to send plain text emails. 
                Text: {
                    Charset: "UTF-8",
                    Data: message
            Subject: {
                Charset: 'UTF-8',
                Data: subject
        ReturnPath: from ? from :,
        Source: from ? from :,

    ses.sendEmail(params, (err, data) => {
        if (err) {
            return console.log(err, err.stack);
        } else {
            console.log("Email sent.", data);

module.exports = {sendEmail};

In the above file, we have created a function called sendEmail which can be called from anywhere in Node.js application to send an email via SES API.

Now create config.js file in the root directory and specify AWS access key, access secret and other required information.


module.exports = {
    'aws': {
        'key': 'YOUR_ACCESS_KEY',
        'secret': 'YOUR_ACCESS_SECRET',
        'ses': {
            'from': {
                // replace with actual email address
                'default': '"" <>', 
            // e.g. us-west-2
            'region': 'YOUR_ACCESS_REGION' 

Create server.js File

Let's create server.js file in our project root directory that will be used to run our Node.js application:


const express = require('express');
const bodyParser = require('body-parser');
const app = express();

const sesClient = require('./ses-client');

app.use(bodyParser.urlencoded({ extended: false }));  

app.get('/', (req, res) => {
    // call sesClient to send an email
    sesClient.sendEmail('', "Hey! Welcome", "This is the body of email");
    res.send('Email is sent!');

app.listen(3000, () => {
    console.log('App is listening on port 3000');

Source code: Download the complete source code from GitHub available under MIT license.

Run the application

To execute the project, run the following command in the terminal:

$ npm run start

It will start the application server listening on port 3000 for connections. To test the solution, open the following URL in your browser window: http://localhost:3000. It is only a basic example to test the solution. If you have any questions related to this tutorial, tweet me anytime.

✌️ Like this article? Follow me on Twitter and LinkedIn. You can also subscribe to RSS Feed.