· 9 years ago · Oct 17, 2016, 05:48 PM
1var email_batch = []
2
3
4function loadXMLDoc(email_id) {
5 var xmlhttp;
6
7 if (window.XMLHttpRequest) {
8 // code for IE7+, Firefox, Chrome, Opera, Safari
9 xmlhttp = new XMLHttpRequest();
10 } else {
11 // code for IE6, IE5
12 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
13 }
14
15 xmlhttp.onreadystatechange = function() {
16 if (xmlhttp.readyState == 4 ) {
17 if(xmlhttp.status == 200){
18 if(xmlhttp.responseText.indexOf("is valid") > 0) {
19 console.log(email_id)
20}
21 }
22 else if(xmlhttp.status == 400) {
23 alert('There was an error 400')
24 }
25 else {
26 alert('something else other than 200 was returned')
27 }
28 }
29 }
30
31 xmlhttp.open("POST", "/", true);
32 xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
33 xmlhttp.send("email=" + email_id);
34}
35
36function list_valid_email(emails){
37 //console.log(emails)
38 if(emails instanceof Array){
39 for(i = 0; i < emails.length; i++){
40 loadXMLDoc(emails[i])
41 }
42} else {
43 emails_list = emails.split(",")
44 gmail_list = []
45 for(i = 0; i<emails_list.length; i++){
46 gmail_list.push(emails_list[i].trim() + "@gmail.com")
47 }
48
49 list_valid_email(gmail_list)
50
51}
52}
53
54
55function list_valid_email_delay(emails, delay = 1, batch_size = 10) {
56 email_batch = []
57 for(var i = 0; i <= (emails.length); i = i + batch_size) {
58 email_batch.push(emails.slice(i, i + batch_size))
59 }
60 for(var i =0; i < email_batch.length; i = i + 1){
61 setTimeout(list_valid_email, i*delay*1000, email_batch[i])
62 //list_valid_email(email_batch[i])
63
64 }
65}