0
Verify Email
One script reply has been approved by the moderators Verified

Verify email address deliverability with Mailgun. See the docs here

Created by pauloborili 1068 days ago Viewed 15897 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 368 days ago
1
type Mailgun = {
2
  api_key: string;
3
};
4

5
export async function main(
6
  resource: Mailgun,
7
  data: {
8
    address: string;
9
    provider_lookup?: boolean;
10
  }
11
) {
12
  return (
13
    await fetch(
14
      `https://api.mailgun.net/v3/address/validate?address=${
15
        data.address
16
      }&provider_lookup=${data.provider_lookup ?? true}`,
17
      {
18
        method: "POST",
19
        headers: {
20
          Authorization:
21
            "Basic " +
22
            Buffer.from(`api:${resource.api_key}`).toString("base64"),
23
        },
24
      }
25
    )
26
  ).json();
27
}
28