Buy Now!

Documentation & Code Samples

Hello and thank you for your interest in emailChecker. The emailChecker class is simple and easy to use! This powerful class can be used for batch processing to perform list hygiene or integrated seemlessly into your web forms and called via ajax to decrease the number of signup errors, and bounce emails by up to 50%!

Here you will find basic usage instructions and example code to get emailChecker up and running in a matter of minutes. The purchase download includes bare bones and ajax demo files as shown on this site to make integration a breeze.


Bare bones example:


<?php

$e = 'johndoe@hotmail.cmo'; // email address with a typo
	
require_once('email_checker.class.php'); //include emailChecker.class.php file
$emailChecker = new emailChecker; // Make a new instance

$response = $emailChecker->check(e); //run core check function with all options

print_r($response); 
	
?>

Easy just like everything from us! Just include it, make a new instance of it, and check your addresses!


Expanded example:


<?php

$e = 'johndoe@hotmail.cmo'; // email address with a typo
	
require_once('email_checker.class.php'); //include emailChecker.class.php file
$emailChecker = new emailChecker; // Make a new instance

$emailChecker->check(e);
$emailChecker->filter_domains = 1; //reject domains of known spammers and junk signups
$emailChecker->filter_dea = 1; //reject known DEA (disposable email address) providers/domains
$emailChecker->filter_unsubscribers = 1; //reject known DEA (disposable email address) providers/domains
$emailChecker->filter_google_dea = 1; //remove . and +'s from google and gmail addresses (simple dea's)
$emailChecker->fix_typos = 1; //correct common email TLD typos using algorithm
$emailChecker->fix_levenshtein_typos = 1; //use Levenshtein algorithm to correct typos
$emailChecker->auto_correct_typos = 0; ///only show typo correction suggestions (instead of actually fixing them)
$emailChecker->check_mx = 1; //check the mx server of the email TLD. requires checkdnsrr() function.
$emailChecker->smtp_test = 1; //Connect to MX server and simulate mail send with SMTP
$emailChecker->supress_output = 0; //suppress output, and just return true/false

$response = $emailChecker->check(e); //run core check function with all options

print_r($response); 
	
?>

In this example we've included some of the core configuration options that can be tweaked to suite your environment and needs.


Live check/Ajax example:


<?php
if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {

	$e = strip_tags(stripslashes($_REQUEST['e']));

	require_once('inc/email_checker.class.php'); //include emailChecker.class.php file

	$emailChecker = new emailChecker; // Make a new instance
	$emailChecker->auto_correct_typos = 0; 
	$emailChecker->check_mx = 0;
	$emailChecker->smtp_test = 0; 
	$emailChecker->supress_output = 1; 
	$response = $emailChecker->check($e);

	die(json_encode($response));

}else{
	die('Unauthorized access prohibited.');
}
?>

Create the above php script on your server to be called form your signup, contact and opt-in forms via ajax.

Integration with web forms


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){

	$('#mailing_list').submit(function(){

		//grab email field from opt-in form
		var e = $('#email').val();
		
		//hide feedback display
		$('#feedback').fadeOut('fast');
		
		//if email field has content in it
		if(e){
		
			//make ajax call to email_checker_ajax.php and pass email value
			$.ajax({
			  url: "email_checker_ajax.php?e="+escape(e),
			  success: function(data){
			  
				//capture response and convert to array
				var r = $.parseJSON(data);
				
				//emailChecker api responsed with success
				if(r['result']['success']){
					$('#feedback').html('<b>' + e + '</b> is valid.');
				}else{
					//emailChecker api responded with failure and typo suggestion
					if(r['result']['suggestion']){
						$('#feedback').html('Did you mean <b><a href="#" onclick="$(\'#email\').val(\'' + r['result']['suggestion'] + '\'); $(\'#feedback\').fadeOut(\'fast\'); return false;">' + r['result']['suggestion'] + '</a></b>?');
					}else{
						//emailChecker responded with failure
						$('#feedback').html('Sorry, <b>' + e + '</b> is not a valid email address.');
					}
				}
			  }
			});
			
			//display feedback
			$('#feedback').fadeIn('slow');
						
		}else{
			//email field is empty, display feedback
			$('#feedback').html('Please enter your email address.');
			$('#feedback').fadeIn('slow');
		}

		//return false because this is demo mode
		return false;
	});
});
</script>

</head>
<body>
<form method="post" action="post" id="mailing_list">
	<div>
		Name: <input type="text" name="name" id="name" value="" placeholder="Your Name" />
	</div>

	<div class="email_field">
		Email: <input type="text" name="email" id="email" value="" placeholder="Your Email" /><div id="feedback"></div>
	</div>
	<input type="submit" value="Sign Up" />
</form>

</body>
</html>

Thanks again for your interest in the emailChecker class. As you can see the usage for this powerful class are limitless. If you have any questions that are beyond the scope of this help site, please feel free to contact for assistance. Thanks again!