Skip to content

Contact

Source: src/AWS/SES/Contact.ts

An Amazon SES v2 contact — a single email address on a SES.ContactList, with its own topic subscription preferences and unsubscribe state.

Basic Contact

import * as SES from "alchemy/AWS/SES";
const list = yield* SES.ContactList("Newsletter", {});
const contact = yield* SES.Contact("Subscriber", {
contactListName: list.contactListName,
emailAddress: "reader@example.com",
});

Contact with Topic Preferences

const contact = yield* SES.Contact("Subscriber", {
contactListName: list.contactListName,
emailAddress: "reader@example.com",
topicPreferences: [
{ TopicName: "product-updates", SubscriptionStatus: "OPT_IN" },
{ TopicName: "promotions", SubscriptionStatus: "OPT_OUT" },
],
});

Unsubscribe a Contact from Everything

// unsubscribeAll overrides every per-topic preference.
const contact = yield* SES.Contact("Subscriber", {
contactListName: list.contactListName,
emailAddress: "reader@example.com",
unsubscribeAll: true,
});
// Serialized to the JSON string SES stores; re-ordering the keys is not a
// change, so this does not churn on every deploy.
const contact = yield* SES.Contact("Subscriber", {
contactListName: list.contactListName,
emailAddress: "reader@example.com",
attributes: { plan: "pro", signupSource: "docs" },
});