Send email from DaloyJS with AWS SES
Amazon Simple Email Service (SES) is AWS's pay-as-you-go transactional and bulk email service. This guide uses SESv2: the current API, through the AWS SDK for JavaScript v3. Best fit when you already run on AWS (Lambda, ECS, Fargate, EC2) or need very low per-message cost.
- 01requestRoute handlerSESv2Clientsend(SendEmailCommand)FromEmailAddress, Destination, Content.Simple
- 02requestSESv2ClientAmazon SESSigned HTTPS call (AWS SigV4)ses:SendEmail via IAM role or keys
- 03responseAmazon SESRoute handlerAcceptedout.MessageId returned as { id }
- 04asyncAmazon SESSNS / EventBridgeDelivery, bounce, complaint eventsvia a configuration set (ConfigurationSetName)
1. Provision
- In the AWS console, open Amazon SES → Verified identities and verify either an email address (for development) or your sending domain (for production). Add the SPF, DKIM, and DMARC records SES shows you.
- New accounts start in the SES sandbox: you can only send to verified addresses. Request production access from Account dashboard before launching.
- Create an IAM principal that can call
ses:SendEmail. Prefer an execution role attached to your Lambda or container, avoid long-lived access keys.
2. Install
The v3 SDK is modular, install only the SESv2 client. It works on Node 18+ and is compatible with the Lambda adapter.
3. Environment variables
4. Plugin
The SDK reads credentials from the standard AWS provider chain (env vars, shared config file, IMDS, IRSA on EKS, Lambda role), so the client itself takes no secrets.
5. Use it in a route
Templates & attachments
SESv2's SendEmailCommand accepts three content variants:
Content.Simple: subject + text/HTML body (used above). Also supports anAttachmentsarray with base64RawContent,FileName, andContentType.Content.Raw.Data: a fully MIME-encoded message (use mailcomposer ornodemailer's composer if you need rich attachments).Content.Template: render an SES template byTemplateNamewith a JSONTemplateDatapayload. Create templates ahead of time withCreateEmailTemplateCommand.
Runtimes
- Node / Bun / Deno / AWS Lambda: works out of the box. On Lambda, omit access keys and let the execution role supply credentials.
- Cloudflare Workers / Vercel: the SDK can run there but uses a Web Crypto signer; pin
@aws-sdk/client-sesv2≥ 3.700 and passcredentialsexplicitly (the default provider chain expects Node APIs).
Observability
SES publishes delivery, bounce, and complaint events to SNS, EventBridge, or Kinesis Firehose via a configuration set. Add ConfigurationSetName to SendEmailCommandInput to opt in.
See also Resend, SendGrid, and the email integrations overview.