Tutorial: Filtering Bad Email Domains Like “DodgeIt.com”

March 21st, 2007

If you need a valid and active email address as part of your registration process, you may have come across services like “DodgeIt.com” that allow users to create temporary addresses for the sole purposes of completing the email validation process.

For example, let’s say you have an e-commerce site and in order to send receipts, you need to ensure that the user has provided a legitimate email account. During registration, you accept the user’s information and send a confirmation e-mail containing a validation link that completes the registration process. Someone who wishes to remain anonymous for whatever reason could use a service like DodgeIt and spoof your validator.

Blocking these domains is a relatively simple matter. Simply add the following function to your validation pass and flag matching domains as an address that you do not accept.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function filterBadEmailDomains($email) {

// Filters against a list of "bad" domains.
// Returns FALSE if the domain is bad; TRUE if it's good
// Add additional banned domains to the $blockedDomainArr array

$blockedDomainArr = array('dodgeit');
$retVal = true;
$emailParts = explode('@',$email);

foreach($blockedDomainArr as $blockedDomain) {

if(strstr($emailParts[1],$blockedDomain)) {
$retVal = false;
}

}

return $retVal;

}

This example singles out DodgeIt, but as other similar services come on line, you can add their domains to the $blockedDomainArr array and include them in your validation.

Enjoy.

Sphere: Related Content

Leave a Reply

Need help? Post your question on the StringFoo Forums.

You must be logged in to post a comment.