Skip to main content

Command Palette

Search for a command to run...

🚀 Mastering Amazon SES: A Complete Guide to Sending Emails with Node.js

Updated
3 min read
🚀 Mastering Amazon SES: A Complete Guide to Sending Emails with Node.js

In today's web applications, sending emails is more than a feature—it's a necessity. From signup confirmations and OTPs to newsletters and receipts, email is the lifeline of user communication.

One of the most powerful tools for this is Amazon SES (Simple Email Service). It's fast, cost-effective, and scales as you grow.


📬 What is Amazon SES?

Amazon SES (Simple Email Service) is a cloud-based service by AWS designed to help developers send both transactional and marketing emails.

Whether you're sending account verification links or monthly newsletters to thousands of users, SES has you covered with its high deliverability and flexibility.


🛠 Key Features of Amazon SES

✅ 1. Transactional & Marketing Email Support

Send both individual, real-time emails (like order confirmations) and bulk campaigns (like promotions).

📊 2. Analytics and Deliverability

Track:

  • Delivery success

  • Bounces

  • Complaints

  • Opens (if configured via AWS Pinpoint)

You can also use Amazon CloudWatch and SNS for monitoring.

🔐 3. DKIM, SPF, and DMARC Authentication

SES supports domain verification and email authentication protocols to improve deliverability and reduce spam.

📤 4. Flexible Sending Options

  • Send via SMTP

  • Use the AWS SDK / API

  • Integrate with other AWS services (like Lambda or Step Functions)

🛡 5. Security and Access Control

  • IAM roles for fine-grained permissions

  • VPC integration

  • TLS encryption for SMTP

💰 6. Pay-as-you-go Pricing

You only pay for what you send. Plus, if your app is hosted on Amazon EC2, you get 62,000 free emails per month.


🧑‍💻 Using Amazon SES in Node.js

Let’s build a simple utility that sends plain-text emails using Amazon SES.

Step 1: Install AWS SDK

npm install aws-sdk

Step 2: Configure Your Environment

Make sure your .env file contains:

AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY
SES_VERIFIED_EMAIL=your_verified@domain.com

Step 3: Create the Email Utility

import AWS from "aws-sdk";

AWS.config.update({
  region: process.env.AWS_REGION,
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
});

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

export const sendEmail = async (toEmail, subject, bodyText) => {
  const params = {
    Source: process.env.SES_VERIFIED_EMAIL,
    Destination: {
      ToAddresses: [toEmail],
    },
    Message: {
      Subject: { Data: subject },
      Body: {
        Text: { Data: bodyText },
      },
    },
  };

  return ses.sendEmail(params).promise();
};

Step 4: Use it in Your App

import { sendEmail } from "./utils/sendEmail.js";

const subject = "Your Booking is Confirmed!";
const body = `Hi there,

Thanks for booking with us! Your session is confirmed.

Google Meet Link: https://meet.google.com/abc-defg-hij

Best regards,
Team`;

await sendEmail("user@example.com", subject, body);

🧪 Does the Recipient Need to be Verified?

It depends on your SES environment:

ModeFrom Email Verified?To Email Verified?
Sandbox✅ Yes✅ Yes
Production✅ Yes❌ No

🔓 How to Move Out of Sandbox

  1. Go to the SES Console

  2. Navigate to "Account Dashboard" → "Edit your account details"

  3. Choose "Request production access"

  4. Submit a request with:

    • Use case description

    • Website URL

    • Expected volume


🎨 HTML Emails? Attachments?

Yes! SES supports:

  • HTML email bodies

  • Multi-part MIME (text + HTML)

  • Attachments via base64

  • Templated emails (with SES templates)

Want to build beautiful, branded emails? Use libraries like:

  • mjml

  • nodemailer

  • react-email


✅ Conclusion

Amazon SES is one of the most scalable, cost-effective solutions for sending emails in modern web apps. With Node.js, it’s easy to integrate and automate everything from transactional notifications to large campaigns.

Once you're out of sandbox mode, the sky's the limit 🚀