Verify Email

Verify email address deliverability with Mailgun. [See the docs here](https://documentation.mailgun.com/en/latest/api-email-validation.html)

Script mailgun Verified

by pauloborili ยท 6/6/2022

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 362 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