Email SDK
Adapters

AWS SES

Configure the AWS SES v2 SendEmail adapter.

The AWS SES adapter calls the SES v2 SendEmail API directly with SigV4-signed fetch requests. It does not add a runtime dependency on the AWS SDK.

AWS SES logo
AWS SES
@opencoredev/email-sdk/ses
OfficialNot API testedRequest tested
Open website

Before live sends

Use credentials that can call SES v2 SendEmail in the selected region. Verify the sender identity in that same region, and confirm whether the AWS account is still in the SES sandbox before sending to arbitrary recipients.

Configure

import { createEmailClient } from "@opencoredev/email-sdk";
import { ses } from "@opencoredev/email-sdk/ses";

const email = createEmailClient({
  adapters: [
    ses({
      accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
      sessionToken: process.env.AWS_SESSION_TOKEN,
      region: process.env.AWS_REGION!,
    }),
  ],
});

Send

const result = await email.send({
  from: "Acme <hello@acme.com>",
  to: [{ email: "user@example.com", name: "Ada" }],
  cc: "billing@example.com",
  replyTo: "support@example.com",
  subject: "Welcome",
  html: "<p>Your workspace is ready.</p>",
  headers: {
    "X-Template": "welcome",
  },
  tags: [{ name: "type", value: "welcome" }],
  attachments: [
    {
      filename: "welcome.txt",
      content: "Welcome to Acme.",
      contentType: "text/plain",
    },
  ],
});

console.log(result.provider, result.messageId);

SES maps Email SDK tags to SES EmailTags, headers to Simple.Headers, and attachments to SES v2 Simple.Attachments. It does not map Email SDK metadata.

Options

OptionTypeRequiredNotes
accessKeyIdstringYesAWS access key ID.
secretAccessKeystringYesAWS secret access key.
regionstringYesSES region, for example us-east-1.
sessionTokenstringNoRequired for temporary credentials.
baseUrlstringNoDefaults to https://email.{region}.amazonaws.com.
fetchtypeof fetchNoUseful for tests or custom runtimes.
charsetstringNoDefaults to UTF-8.
configurationSetNamestringNoSES configuration set for sends through this adapter.

Response

The adapter returns the SES MessageId as id and messageId.

CLI smoke test

AWS_ACCESS_KEY_ID=... \
AWS_SECRET_ACCESS_KEY=... \
AWS_REGION=us-east-1 \
npx email-sdk send --adapter ses \
  --from "Acme <hello@acme.com>" \
  --to user@example.com \
  --subject "Welcome" \
  --html "<p>Your workspace is ready.</p>"

On this page