How to Block Disposable Email Addresses (Tutorial)
In this article, I'll show you how to block temporary email addresses from your platform. We'll explore DIY methods, free GitHub lists, and how you can use a solution like UserCheck to save time and improve lead quality.
Disposable email services like Temp Mail, 10MinuteMail, and EmailOnDeck are designed to let users create temporary email addresses to bypass email verification. These services are commonly used by spammers, bots, or people looking to avoid using their real email address. For businesses, this means wasted resources, fake leads, and potential security risks. So, how do we block these fake emails?
If you prefer to learn via a video format, here's a YouTube video we recorded covering the same content:
Option 1: Using an API (UserCheck)
The first and most effective option is to use an API, like UserCheck, which is specifically designed to block disposable email addresses.
Here's why this is a better approach:
- Always Up-to-Date: UserCheck maintains a database of disposable email domains and automatically updates it, so you don't have to.
- Simple Integration: With just one API call, you can verify whether an email is temporary or valid.
- Freemium Tier: UserCheck offers 1,000 free requests per month, so you can try it out without any upfront cost.
- Comprehensive Support: Access to detailed documentation and customer support to help with integration.
Example request:
curl https://api.usercheck.com/email/[email protected]
Example response:
{
"status":200,
"email":"[email protected]",
"domain":"example.com",
"mx":false,
"disposable":false,
"public_domain":false,
"relay_domain":false,
"alias":false,
"role_account":true,
"did_you_mean":null
}
The response will tell you whether the email is disposable, giving you the power to block fake signups instantly. UserCheck's email validation API also offers a variety of other email verification features you might find useful.
How to integrate UserCheck into your system:
- Go to UserCheck.com and sign up for a free account.
- Get your API key from the dashboard.
- Use the documentation to add the API to your signup flow. Most teams can set it up in under 10 minutes.
- Test it out using your free 1,000 requests.
Option 2: The DIY Approach
Next is a simple option: a DIY approach.
You can manually create a basic domains list of disposable email providers that you find on fake email generator websites. Then use it to block these domains in your signup flow. For example, you could write a basic script in Python or JavaScript to compare email domains against your blocklist.
# Latest domains from temp-mail.org
disposable_domains = [
"venfee.com",
"xoroda.com",
"walshun.com",
"vmmod.com",
"nozamas.com",
"kazvi.com",
"gitted.com",
"kimasoft.com",
"exoular.com",
"cashbn.com",
"cpaurl.com",
]
def is_valid_email(email):
domain = email.split('@')[-1]
return domain not in disposable_domains
email = "[email protected]"
print(is_valid_email(email)) # Output: False
This approach works, but it has major downsides:
- You need to constantly monitor and update your blocklist, as new disposable email providers pop up every day.
- It's time-consuming and not scalable if you're running a business.
Option 3: Using Free GitHub Lists
The final option is to use a free blocklist from GitHub. There are open-source repositories that maintain updated lists of disposable email domains. You can integrate these into your project for free.
Here are the most popular ones:
- disposable-email-domains/disposable-email-domains
- wesbos/burner-email-providers
- 7c/fakefilter
- ivolo/disposable-email-domains
And here's a Python script to fetch the domains from disposable-email-domains/disposable-email-domains
:
import requests
# GitHub API URL for the raw file content
url = "https://api.github.com/repos/disposable-email-domains/disposable-email-domains/contents/disposable_email_blocklist.conf"
# Optional: Add a GitHub token if you have rate limit issues
headers = {
# "Authorization": "token YOUR_GITHUB_PERSONAL_ACCESS_TOKEN" # Uncomment and add your token if needed
}
try:
# Send GET request to GitHub API
response = requests.get(url, headers=headers)
response.raise_for_status() # Raise an error for HTTP issues
# Get the content of the file
blocklist_content = response.text
# Parse each line of the file
blocklist_domains = [line.strip() for line in blocklist_content.splitlines() if line.strip()]
# Print the parsed list
for domain in blocklist_domains:
print(domain)
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
While this is more scalable than DIY, it has its own challenges:
- You'll need to periodically update the list manually or set up automated updates.
- These lists are often incomplete or outdated, with updates typically occurring every few weeks.
- They lack professional verification because they depend on volunteers to submit new domains.
Conclusion
So, to recap:
- If you're just starting out, a DIY approach might work, but it requires constant maintenance.
- GitHub lists are a good step up, but they can be incomplete and still require effort to integrate.
- An API like UserCheck is the easiest and most reliable way to block disposable email address services without wasting time.