# AWS SES (/docs/v/0.6.0/adapters/ses)



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.

<ProviderBadge adapter="ses" />

## Before live sends [#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 [#configure]

```ts
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 [#send]

```ts
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 [#options]

| Option                 | Type           | Required | Notes                                                 |
| ---------------------- | -------------- | -------- | ----------------------------------------------------- |
| `accessKeyId`          | `string`       | Yes      | AWS access key ID.                                    |
| `secretAccessKey`      | `string`       | Yes      | AWS secret access key.                                |
| `region`               | `string`       | Yes      | SES region, for example `us-east-1`.                  |
| `sessionToken`         | `string`       | No       | Required for temporary credentials.                   |
| `baseUrl`              | `string`       | No       | Defaults to `https://email.{region}.amazonaws.com`.   |
| `fetch`                | `typeof fetch` | No       | Useful for tests or custom runtimes.                  |
| `charset`              | `string`       | No       | Defaults to `UTF-8`.                                  |
| `configurationSetName` | `string`       | No       | SES configuration set for sends through this adapter. |

## Response [#response]

The adapter returns the SES `MessageId` as `id` and `messageId`.

## CLI smoke test [#cli-smoke-test]

```bash
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>"
```
