Skip to content

Instantly share code, notes, and snippets.

@tjtate
Created October 29, 2019 15:09
Show Gist options
  • Save tjtate/d7b3e448d31789898f8da2ca46c652e2 to your computer and use it in GitHub Desktop.
Save tjtate/d7b3e448d31789898f8da2ca46c652e2 to your computer and use it in GitHub Desktop.
jQuery( document ).ready(function($) {
//target whatever submits the form.
$('button.lp-pom-button').on('click', function (e) {
//prevent the form from submitting
e.preventDefault();
//get the email address
var emailaddress = $('.form_elem_email').val();
//call the validation function
eoValidate(emailaddress, function (response){
/*
Response codes and meanings
0 Retry Unable to establish a validation resopnse from the ISP - retry again.
1 Verified Email address is deliverable.
2 Undeliverable Email address does not exist, invalid, suspended, over quota or disabled.
3 Catch All Domain of email address accepts all mail and it is impossible to determine validity. If the email address was acquired organically or you have confidence in the validity of the email address, then send at your discretion.
4 Role Email is associated to common distribution groups. abuse@, sales@, no-reply@, test@ and etc.
5 Malformed Email address does not conform to valid email format.
6 SpamTrap Avoid SpamTrap emails at all cost. Those accounts are kept alive to damage sender reputation.
7 Complainer Complainers are commonly users who like to complain after receiving email. Complaints can vary from ISP notification to cease and desist letters. In some rare cases they can also pursue litigation. These are valid addresses but we do not recommend sending mail.
9 Bot Bots are email accounts that are maintained by bot servers for sending spam, clicking every link and other harmful or harmless activities.
10 Seed Account Seed accounts are known email addresses that are maintained in masses for various reasons. Most commonly they are used for compliance tracking.
11 Unknown Email address cannot be verified at the moment. Retrying later may succeed.
12 Unauthorized Unauthorized API access. This error will be returned if IP or URL are not whitelisted and there are over 50 requests within 24 hours.
13 Disposable Email Temporary email account that is designed to only be used few times before expiring.
20 Suppressed Email is in known suppression list. This is only available when advanced validation is enabled on particular list.
*/
//just checking if its verified
if (response.ResultId == 1) {
$('form').submit();
}
//not verified
else {
alert('This email address is not valid. Please try again with another email');
}
})
});
function eoValidate(email, callback) {
//just making an ajax request to email oversight
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.emailoversight.com/api/EmailValidation?apitoken=XXXXXX&listid=51593&email="+email,
"method": "GET"
};
$.ajax(settings).done(function (response) {
if (typeof callback == 'function')
callback(response);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment