Detect Disposable Email with Garbage Domain

Viewed 2428

I am developing website using php/codeigniter.

I have downloaded a list of temporary email domains from github (https://gist.github.com/adamloving/4401361)

I integrated this to my website to filter and validate email address.But I noticed that some domains are garbage and cannot detect by the list provided.

Please image below.

enter image description here

Currently Im using this code to filter/validate emails:

  public function is_temp_mail($mail='')
  {
    $this->db->select('domain');
    $this->db->from('table_disposal_email_domains');
    $domains=$this->db->get()->result();
    foreach($domains as $domain)
    {
      list(,$mail_domain) = explode('@',$mail);
      if(strcasecmp($mail_domain, $domain->domain) == 0){
            return true;
      }
    }
    return false;
  }

How to block garbage domains.Please help.

3 Answers

One of the issue with disposable emails is that new domains are added daily. So, maintaining your own list isn't gonna be enough after a few days.

You can use the validator.pizza API, which is free and updated frequently.

Disclaimer: I made this API

I wrote a simple API for determining the domains of temporary mails, all you need to determine the temporary mail is to send a GET request:

https://api.testmail.top/domain/check/data=example@mail.com&ip=8.8.8.8

with authorization header:

Authorization: Bearer XXXXXXXXXX.XXXXXXXXXX.XXXXXXXXXX

and in response you will receive a message like this if the mail turns out to be temporary:

{
    "error": 0,
    "result": false,
    "message": "This domain is in Blacklist"
}

you will receive such an answer if the mail turns out to be trusted (something like gmail.com or yahoo.com):

{
    "error": 0,
    "result": true,
    "message": "This domain is in Whitelist"
}

I have described error codes and more detailed instructions on this page

Related