Validate Email

Email Address Validation is a paid service from Sendgrid and it's available to Email API Pro and Premier level accounts only.

Script sendgrid Verified

by rubenmanhague ยท 6/6/2022

The script

Submitted by hugo989 Bun
Verified 3 days ago
1
import sendgrid from "@sendgrid/client@^7.7.0";
2

3
type Sendgrid = {
4
  token: string;
5
};
6
export async function main(
7
  api_token: Sendgrid,
8
  email: string,
9
  source?: string,
10
) {
11
  sendgrid.setApiKey(api_token.token);
12

13
  const request = {
14
    url: `/v3/validations/email`,
15
    method: "POST",
16
    body: {
17
      email,
18
      source,
19
    },
20
  };
21

22
  try {
23
    const [_, body] = await sendgrid.request(request);
24
    return body;
25
  } catch (error) {
26
    throw Error("\n" + JSON.stringify(error?.response?.body || error));
27
  }
28
}
29

Other submissions
  • Submitted by adam186 Deno
    Created 395 days ago
    1
    import sendgrid from "npm:@sendgrid/client@^7.7.0";
    2
    
    
    3
    type Sendgrid = {
    4
      token: string;
    5
    };
    6
    export async function main(
    7
      api_token: Sendgrid,
    8
      email: string,
    9
      source?: string,
    10
    ) {
    11
      sendgrid.setApiKey(api_token.token);
    12
    
    
    13
      const request = {
    14
        url: `/v3/validations/email`,
    15
        method: "POST",
    16
        body: {
    17
          email,
    18
          source,
    19
        },
    20
      };
    21
    
    
    22
      try {
    23
        const [_, body] = await sendgrid.request(request);
    24
        return body;
    25
      } catch (error) {
    26
        throw Error("\n" + JSON.stringify(error?.response?.body || error));
    27
      }
    28
    }
    29