Skip to content

Instantly share code, notes, and snippets.

@w3guy
Created October 7, 2013 09:11
Show Gist options
  • Save w3guy/66cf3822c67dea402652 to your computer and use it in GitHub Desktop.
Save w3guy/66cf3822c67dea402652 to your computer and use it in GitHub Desktop.
Protecting Your PHP Web App From Disposable Email Users via BDEA api http://w3guy.com/protect-php-app-disposable-email/
<?php
function checkDEAfilter($email)
{
$key = "d619f9ad24052ad785d1edf65bbd33b4"; //replace with your API key
$request = "http://check.block-disposable-email.com/easyapi/json/".$key."/" .$email;
$response = file_get_contents($request);
$dea = json_decode($response, true);
if ($dea['request_status'] == 'success') {
if ($dea['domain_status'] != "ok") {
//Access Denied
return false;
} else {
// Access Granted
return true;
}
} else {
// something else went wrong with the address (maybe a malformed domain)
return "false";
}
}
<?php include "deaFilterClient.php";?>
<form action="" method="post">
<label for="male">Email Address</label><br/>
<input type="text" name="email" id="email" value="<?php echo (isset($_POST["email"])) ? $_POST["email"] : "";?>"/>
<?php
// validate and detect if email is disposable or not
if (isset($_REQUEST["email"]))
{
if ( !checkDEAfilter($_REQUEST["email"])) {?>
<img src="images/cancel.png"/> &nbsp; &nbsp; <input type="submit" value="validate"/> <?php }
else echo '<img src="images/accept.png"/>';} else echo '<input type="submit" value="validate"/>';
?>
<br/><br/>
<input type="submit" name="submit" value="submit form"/>
</form>
// validate the form before sent to the server for processing
// Check if email is set and if it not disposable
<?php if((isset($_REQUEST["submit"])) && (checkDEAfilter($_REQUEST["email"]))) {
echo "your email is " . $_REQUEST['email'] ;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment