sethserver.com Subscribe
Pirate robot standing on a ship firing a cannon of envelopes and packages into the ocean

How to Send Email from Replit with AWS SES: DNS, DKIM & IAM Setup Guide

By Seth Black • Updated: September 17, 2026

Programming · 4 min read

Want more posts like this in your inbox? One email a week, no spam - subscribe to the newsletter.

You can build a whole app on Replit in an afternoon. Then you try to send one email and you're knee-deep in DNS records at 1am wondering why you didn't just use a third-party service.

AWS SES is my go-to for transactional email. It's cheap and it works. I've been using it for years. The setup has some annoying parts, but it's way better than what we used to do. I remember buying Dell servers, installing FreeBSD, configuring qmail or sendmail, manually editing DNS zone files, and hoping it all worked.

Step 1: Verify your domain (and turn on DKIM)

In AWS Console:

AWS will hand you DNS records. Usually:
- 3 CNAME records for DKIM
- Sometimes a TXT record for domain ownership

DKIM, in plain terms

DKIM is a cryptographic signature on your outgoing mail.

Without DKIM, your email might still send, but it'll end up in spam or get rejected outright. Gmail and Outlook will treat it like junk mail. Just set it up.

Step 2: Add the DNS records (don't paste the whole domain into "Name")

This is where most people get stuck for an hour.

SES gives you something like:

Most DNS providers want only the subdomain part in the "Name/Host" field.

Provider quirks

Check propagation:

dig CNAME abc123._domainkey.yourdomain.com

DNS can take minutes or up to 48 hours. Usually it's under an hour.

Step 3: Get out of the SES sandbox

New SES accounts start in sandbox mode. That means you can only send to verified addresses.

SES - Account dashboard - Request production access

They'll ask:
- what you're sending
- expected volume
- how you handle bounces/complaints

Approval usually takes 24-48 hours. While you wait, verify a couple email addresses so you can test.

Step 4: Create IAM credentials for Replit

IAM - Users - Create user: replit-ses-sender

Give it permission. You can attach AmazonSESFullAccess, but I prefer a tight policy:

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": ["ses:SendEmail", "ses:SendRawEmail"],
    "Resource": "*"
  }]
}

Create an access key:
- Use case: Application running outside AWS
- Save the Access Key ID + Secret Access Key (you won't see the secret again)

Step 5: Add Replit secrets

In Replit "Secrets":

That from address should be on your verified domain.

Python example (boto3)

import os
import boto3
from botocore.exceptions import ClientError

ses = boto3.client(
    "ses",
    region_name=os.environ["AWS_REGION"],
    aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
    aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
)

def send_email(to_address: str, subject: str, body_text: str, body_html: str | None = None) -> str:
    source = os.environ["SES_FROM_EMAIL"]

    body = {"Text": {"Data": body_text, "Charset": "UTF-8"}}
    if body_html:
        body["Html"] = {"Data": body_html, "Charset": "UTF-8"}

    try:
        resp = ses.send_email(
            Source=source,
            Destination={"ToAddresses": [to_address]},
            Message={
                "Subject": {"Data": subject, "Charset": "UTF-8"},
                "Body": body,
            },
        )
        return resp["MessageId"]
    except ClientError as e:
        raise RuntimeError(e.response["Error"]["Message"])

TypeScript example (AWS SDK v3)

import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";

const client = new SESClient({
  region: process.env.AWS_REGION!,
  credentials: {
    accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
  },
});

export async function sendEmail(to: string, subject: string, bodyText: string, bodyHtml?: string) {
  const from = process.env.SES_FROM_EMAIL!;

  const cmd = new SendEmailCommand({
    Source: from,
    Destination: { ToAddresses: [to] },
    Message: {
      Subject: { Data: subject, Charset: "UTF-8" },
      Body: {
        Text: { Data: bodyText, Charset: "UTF-8" },
        ...(bodyHtml ? { Html: { Data: bodyHtml, Charset: "UTF-8" } } : {}),
      },
    },
  });

  const resp = await client.send(cmd);
  return resp.MessageId;
}

Common failures (the ones you'll actually hit)

SES will let you send a lot of email. AWS expects you to not be stupid about it. Watch your bounce rate (keep it under 5%) and complaint rate (under 0.1%), or they'll shut you down fast.

Now you can actually send email from your Replit app without setting up a mail server. You still have to do DNS, though. When you're ready to deploy your Replit app to production, you'll want proper error tracking—consider setting up structured logging so you can debug email delivery issues in production.

-Sethers

Share this post
Newsletter

One email, once a week.

Notes on databases, systems, and the occasional strong opinion about Python. No spam, unsubscribe anytime.

Seth Black
Written by

Seth Black

Engineer and founder based in Texas. Writes about databases, AI, and running things in production. Embeds in small teams as lead engineer.

More from Programming

View all →
Programming

What's the Differences Between Relational, NoSQL, Vectors, and Caches

Apr 14, 2026
Programming

Git and Source Control in AI Land

Apr 14, 2026
Programming

Domains, DNS, and why it feels fragile

Apr 14, 2026