Add email to the Mailgun suppression list. See the docs here
1
type Mailgun = {
2
api_key: string;
3
};
4
5
export async function main(
6
resource: Mailgun,
7
domain: string,
8
data: {
9
address: string;
10
tags: string[];
11
created_at?: string;
12
}[]
13
) {
14
return (
15
await fetch(`https://api.mailgun.net/v3/${domain}/unsubscribes`, {
16
method: "POST",
17
headers: {
18
"Content-Type": "application/json",
19
Authorization:
20
"Basic " + Buffer.from(`api:${resource.api_key}`).toString("base64"),
21
},
22
body: JSON.stringify(data),
23
})
24
).json();
25
}
26