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…

Dicembre 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

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.

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

2 thoughts

  1. Simone ha detto:

    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 ha detto:

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

Comments are closed

Recommended

WP doesn’t send email? try this

Snippets for sending emails with Wordpress

Febbraio 8, 2020

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…

Settembre 2, 2016

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

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

Settembre 22, 2015

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…

Ottobre 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…

Febbraio 21, 2011

ASP equivalent to PHP strip_tags

I’ve found those functions around in the internet and I put them here just to remind how to strip tags…

Febbraio 9, 2010