Block junk emails, spammers and temporary emails

If you need an Email Validator Function, consider this version that includes also the check against common temporary mail services…

December 3, 2013

If you need an Email Validator Function, consider this version that includes also the check against common temporary mail services which should be blocked, since their emails work only for some minutes.
Temporary emails services are web sites that let you open an anonymous email account that works only for a session. They are used to activate temporary accounts, for example for test purposes, or to get a link when a subcription is required and sometimes for sending spam.
Those accounts, from a normal user point of view, can be useful. But as owner of a website, when you find those email in your db, they are just JUNK and you can delete them, since they don’t work.
So this function can help you stop junk accounts, spammers and fake users from your site.

function is_email($Address) { /* stop temporary accounts and email validation */
	if(stristr($Address,"@yopmail.com")) return false;
	if(stristr($Address,"@rmqkr.net")) return false;
	if(stristr($Address,"@emailtemporanea.net")) return false;
	if(stristr($Address,"@sharklasers.com")) return false;
	if(stristr($Address,"@guerrillamail.com")) return false;
	if(stristr($Address,"@guerrillamailblock.com")) return false;
	if(stristr($Address,"@guerrillamail.net")) return false;
	if(stristr($Address,"@guerrillamail.biz")) return false;
	if(stristr($Address,"@guerrillamail.org")) return false;
	if(stristr($Address,"@guerrillamail.de")) return false;
	if(stristr($Address,"@fakeinbox.com")) return false;
	if(stristr($Address,"@tempinbox.com")) return false;
	if(stristr($Address,"@guerrillamail.de")) return false;
	if(stristr($Address,"@guerrillamail.de")) return false;
	if(stristr($Address,"@opayq.com")) return false;
	if(stristr($Address,"@mailinator.com")) return false;
	if(stristr($Address,"@notmailinator.com")) return false;
	if(stristr($Address,"@getairmail.com")) return false;
	if(stristr($Address,"@meltmail.com")) return false;
	return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$/i", $Address);
}

As you can see it’s very simple, it check for bad domains and then performs a normal email validation with regular expressions.

Author

I’m a software engineer, an everyday web developer and a maker. I usually build sites with PHP, within or without WordPress. I build Internet of Things with Arduino and ESP8266. I’m the founder of Rockit.it and Dailybest.it and I’m actually the Chief Technical Officer of Better Days web agency.


Comments on “Block junk emails, spammers and temporary emails”

2 thoughts

  1. Simone says:

    That’s cool but maintaining this list will be a real pain in the ass.
    Why don’t you create a public API with an updated list of all the domains to be considered “junk” and use your function to check against this db?

  2. Giulio Pons says:

    Yes. It’s a good idea. If I found a few hours… :)

Comments are closed

Recommended

Highlight text for search results in PHP

Useful code to highlight text occurences in search results or in a text. How to highlight text in a string…

September 2, 2016

How to add rel=”nofollow” to links with preg_replace()

Adding rel="nofollow" to external link is a good SEO practice.

September 22, 2015

Embedding images in HTML or CSS with PHP

This small function returns an encoded string to embed images, inline, inside your html/css code and reduce the number of…

December 4, 2013

User agent detect with PHP

Small PHP code snippet to make a quick detect if the browser that requests your page is on a mobile…

November 7, 2013

How many times a web link has been shared on Twitter

Twitter share button and Facebook share button are the most used buttons to share links on Internet. You can read…

October 19, 2012

get MySpace events with a PHP function

Here is a function to read the concerts for a myspace band page. This code retrieves the “shows page” for…

February 21, 2011