-
Notifications
You must be signed in to change notification settings - Fork 0
/
bulkEmailChecker.js
52 lines (45 loc) · 1.48 KB
/
bulkEmailChecker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const axios = require("axios");
const { postDataToAppsScript, textDataToArray } = require("./utils");
let email = "[email protected]";
let apikey = "6UQY9TAW2SBJZEIHgm0rnXRxeVCk8duN";
let serviceUri = "https://bulk-api.bulkemailchecker.com/";
// let url = `${serviceUri}?key=${apikey}&email=${email}`;
async function bulkEmailChecker(email) {
let url = `${serviceUri}?key=${apikey}&email=${email}`;
return axios
.post(url)
.then(resp => {
const { status, event } = resp.data;
console.log("RESP", status, event, email);
return resp.data.status;
})
.catch(err => null);
}
async function validateRawEmails(
scriptUrl = "https://script.google.com/macros/s/AKfycbwvj6UAhPMaEPb3p-SshlFeJ_Z2jftVeSwh-K2-I9VG9aaCs0Qd/exec",
emails
) {
emails = textDataToArray();
let verifiedEmails = [];
for (let i = 0; i < emails.length; i++) {
//console.log(arrEmails);
let resp = await bulkEmailChecker(emails[i]);
if (resp === "passed") {
verifiedEmails.push([emails[i]]);
console.log("Verified len:", verifiedEmails.length);
}
if (verifiedEmails.length % 10 === 0 && verifiedEmails.length > 0) {
postDataToAppsScript(scriptUrl, verifiedEmails, "verifiedEmails");
verifiedEmails = [];
}
//console.log(resp);
}
// if (verifiedEmails.length > 0) {
// postDataToAppsScript(scriptUrl, verifiedEmails, "verifiedEmails");
// }
}
// validateRawEmails();
module.exports = {
bulkEmailChecker,
validateRawEmails
};