Re: Re: get domain component from email

From: Date: Tue, 07 Aug 2007 23:21:43 +0000
Subject: Re: Re: get domain component from email
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-260350@lists.php.net to get a copy of this message
Kevin Waterson wrote:
This one time, at band camp, Stut <stuttle@gmail.com> wrote:
Which brings me back to my earlier question of why would you want to do this? I can't think of any reason, but then again it is getting late.
I would like to prevent registration of emails from certain domains that abuse a forum. eg: foo.uy7f564d8d6d.com These domains are registered by the thousands by spammers and because they use dyndns it is impossible to use an IP block. Banning the subdomain is pointless as this is easily changed and they may re-register.
In pseudo-PHP (i.e. untested)... $banned = array('example.net', 'example.co.uk'); list(,$domain) = explode('@', $emailaddress, 2); $banned = false; foreach ($banned as $ban) {
    if ($domain == $ban ||
        preg_match('|\.'.preg_quote($ban).'$|i', $domain))
    {
        $banned = true;
        break;
    }
} if ($banned) die('Bad spammer. *slap*'); Far more efficient than trying to do what you asked for help with no matter how long your banned list gets. -Stut -- http://stut.net/

« previous php.general (#260350) next »