Back to Blog

How to Block Disposable Emails in Python

By Harshit Jain5 min read

If you're running a SaaS, you've probably experienced the pain of fake signups. Users bypass your paywalls, abuse your free tiers, and spam your database using disposable email providers like Mailinator, 10MinuteMail, or Yopmail.

The initial instinct for many Python developers is to just write a quick regular expression (Regex) or maintain a hardcoded list of blocked domains. But as you'll quickly discover, that approach doesn't scale.

The Problem with Regex and Static Lists

Spammers are smart. They constantly rotate domains. A domain that was completely clean yesterday might be used entirely for disposable inboxes today. Maintaining an active list of 100,000+ known burner domains in your application's memory is a massive waste of resources and practically impossible to keep up-to-date manually.

Even worse, if you rely on slow third-party APIs that take 2-3 seconds to respond, you introduce massive latency to your critical onboarding flow. Users drop off if a signup form takes too long to submit.

The Solution: Fast Validation with SignGuard

We built SignGuard exactly for this reason. It handles the heavy lifting of constantly monitoring and updating over 74,781+ disposable domains, and exposes a blazingly fast API so you don't have to think about it.

Here's how easily you can integrate it into your FastAPI, Flask, or Django application in just a few lines of code.

Step 1: Install the SDK

pip install disposable-email-score

Step 2: Implement the Check

You can easily wrap your user registration endpoint. The SDK uses local heuristics first (like checking for invalid syntax or missing MX records) and then calls the SignGuard API for the heavy lifting—returning a response in milliseconds.

from disposable_email_score import evaluate_email

def register_user(email: str, password: str):
    # 1. Check the email before doing anything else
    result = evaluate_email(email)
    
    if result.decision.value == "block":
        return {"error": "Disposable emails are not permitted."}
        
    elif result.decision.value == "review":
        # Optional: Flag for manual review but allow signup
        flag_user_for_review(email)
        
    # 2. Proceed with database insertion
    create_user_in_db(email, password)
    return {"success": "Welcome to the platform!"}

Understanding the Risk Score

The `check_email` method doesn't just return a boolean. It returns a detailed risk profile, including a normalized score from `0.0` to `1.0`.

  • Score > 0.8: Highly likely to be a disposable or spam trap. (Automatically marked as "block").
  • Score between 0.5 - 0.8: Suspicious. Might be a newly registered domain or a catch-all. (Marked as "review").
  • Score < 0.5: Clean, standard email from providers like Gmail or standard corporate domains. (Marked as "allow").

Conclusion

Protecting your database from garbage data doesn't have to slow down your app or consume your engineering team's time. By offloading validation to a dedicated service, you can keep your database clean, your email bounce rates low, and your genuine customers happy.

Ready to stop fake signups in their tracks? Get your free SignGuard API key (200 free checks/mo), explore our API Documentation, or view our Transparent Pricing Plans.