Providers
Amazon SES
Send email through Amazon SES.
import { createClient } from '@nicogenz/emails-sdk';
import { ses } from '@nicogenz/emails-sdk/ses';
const email = createClient({
provider: ses({
region: 'eu-central-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
}),
});
Options
| Option | Type | Required | Description |
|---|---|---|---|
region | string | Yes | The AWS region your SES identities are in. |
accessKeyId | string | Yes | The access key ID of an IAM user or role. |
secretAccessKey | string | Yes | The matching secret access key. |
sessionToken | string | No | The session token for temporary credentials. |
configurationSetName | string | No | The SES configuration set to send with. |
fetch | typeof fetch | No | A custom fetch implementation. |
The credentials need permission for the ses:SendEmail action.
Credentials
The provider doesn't look up AWS credentials on its own. Pass them in explicitly, for example from the environment variables that AWS Lambda sets:
ses({
region: process.env.AWS_REGION!,
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
sessionToken: process.env.AWS_SESSION_TOKEN,
});
Notes
- Requests go to the SES v2 API and are signed with AWS Signature Version 4.
tagsare sent as SESEmailTags. SES only allows ASCII letters, numbers, underscores and dashes in tag names and values.headersare limited to 15 per email by SES.idempotencyKeyisn't supported. Passing one throws anEmailErrorwith the codeunsupported.sendBatchsends the emails one by one, because the SES bulk endpoint only works with stored templates.