Skip to content

EmailIdentity

Source: src/AWS/SES/EmailIdentity.ts

An Amazon SES v2 email identity — a verified email address or domain that you send email from.

Creating the identity starts verification: email-address identities receive a verification email, and domain identities get Easy DKIM tokens (exposed as the dkimTokens attribute) to publish as CNAME records. The identity is usable for sending once verificationStatus is SUCCESS.

Domain Identity

import * as SES from "alchemy/AWS/SES";
const identity = yield* SES.EmailIdentity("Sender", {
emailIdentity: "mail.example.com",
});
// publish identity.dkimTokens as CNAME records to verify

Email Address Identity

const identity = yield* SES.EmailIdentity("Sender", {
emailIdentity: "hello@example.com",
});
// SES emails hello@example.com a verification link
const configSet = yield* SES.ConfigurationSet("Tracking", {});
const identity = yield* SES.EmailIdentity("Sender", {
emailIdentity: "mail.example.com",
configurationSetName: configSet.configurationSetName,
});
// init
const sendEmail = yield* SES.SendEmail(identity);
// runtime
const result = yield* sendEmail({
FromEmailAddress: "hello@mail.example.com",
Destination: { ToAddresses: ["customer@example.com"] },
Content: {
Simple: {
Subject: { Data: "Welcome!" },
Body: { Text: { Data: "Hello from SES." } },
},
},
});