feat: enable List-Unsubscribe headers in campaign emails (#96)

* feat: add `precendence: bulk` header for campaign emails

* feat: create and pass unsubUrl to to email queue for campaign

* fix: add correct `List-Unsubscribe-Post` header value
This commit is contained in:
Marc Seitz
2025-01-22 21:16:12 +01:00
committed by GitHub
parent 2137ba8eab
commit 88ba41059e
3 changed files with 30 additions and 12 deletions
+16 -7
View File
@@ -114,6 +114,7 @@ export async function sendEmailThroughSes({
region,
configurationSetName,
unsubUrl,
isBulk,
}: Partial<EmailContent> & {
region: string;
configurationSetName: string;
@@ -121,6 +122,7 @@ export async function sendEmailThroughSes({
bcc?: string[];
replyTo?: string[];
to?: string[];
isBulk?: boolean;
}) {
const sesClient = getSesClient(region);
const command = new SendEmailCommand({
@@ -155,14 +157,21 @@ export async function sendEmailThroughSes({
}
: undefined,
},
...(unsubUrl
? {
Headers: [
Headers: [
// Spread in any unsubscribe headers if unsubUrl is defined
...(unsubUrl
? [
{ Name: "List-Unsubscribe", Value: `<${unsubUrl}>` },
{ Name: "List-Unsubscribe-Post", Value: "One-Click" },
],
}
: {}),
{ Name: "List-Unsubscribe-Post", Value: "List-Unsubscribe=One-Click" },
]
: []
),
// Spread in the precedence header if present
...(isBulk
? [{ Name: "Precedence", Value: "bulk" }]
: []
),
],
},
},
ConfigurationSetName: configurationSetName,