How to block Disposable Email Addresses in your website's registration form?

后端 未结 11 2211
天命终不由人
天命终不由人 2020-11-29 23:55

I would like to know of the possible ways to block disposable email addresses from registering in my website.

For simplicity, let\'s take the example where the regi

11条回答
  •  不知归路
    2020-11-30 00:47

    You can make two checks: spamhaus sbl query and your own list of blacklisted domains. Something like this:

    private static function __emailDomainCheck($email)
    {
        $domain = preg_replace('/^.*@(.*)/', '$1', $email);
    
        $blacklisted = Database::q('SELECT * FROM ' . Database::T('email_domain_blacklist') . ' WHERE domain = ?', array($domain));
        if($blacklisted->rowCount() > 0)
            return "This email domain is blacklisted!";
    
        $host = gethostbyname($domain);
    
        $rbl  = 'sbl-xbl.spamhaus.org';
        $rev = array_reverse(explode('.', $host));
    
        $lookup = implode('.', $rev) . '.' . $rbl;
    
        if ($lookup != gethostbyname($lookup))
        {
            return "Mail host is listed in $rbl!";
        }
        return '';
    }
    

提交回复
热议问题