How to block disposable email addresses without blocking real users
A build guide for the gate itself: where the check belongs, how to keep the list current, what to return when it fires, and how to test it without breaking your own CI.
On this page
- Decide what “blocked” means before you write code
- Put the check on the server, in one function
- Vendor the blocklist and refresh it on a schedule
- Add one DNS lookup for the domains no list has seen
- Allowlist on purpose, and check it first
- Choose the response, then log every block
- Test the gate, and test the mail it depends on
The short answer to how to block disposable email addresses: reduce the address to its registrable domain, match it against a blocklist you vendored into your repo, run one MX lookup for the domains no list carries yet, and require a confirmed address before you hand out anything expensive. The detection signals are cheap. The hard part is the policy around them, and that is where teams lose real customers.
The companion post on the detection signals behind a disposable email check covers the mechanism. This one is the build: where the code goes, how the list stays current, and what you return when the gate fires.
Decide what “blocked” means before you write code
Three enforcement levels exist, and picking one for the whole product is the mistake.
A hard reject at the form is the most satisfying and the most expensive: it fires on forwarding and alias users, and on domains that stopped being disposable long before your copy of the list did. Friction means the account is created but the expensive actions stay locked. Verify then grant means nothing irreversible happens until a code or link sent to that address comes back.
Most teams asking how to block disposable email addresses actually want the third one. Block the action, not the account: free credit, refunds, review posting, invite sending, API keys. A throwaway inbox is temporary by definition, so anything you deliver later fails without your help: an InboxDome inbox lives 24 hours by default and at most 7 days, as the temporary inbox lifetime page sets out.
Put the check on the server, in one function
Client-side validation is a hint. MDN says it outright: HTML form validation is not a substitute for server-side checks, since anyone can edit the markup or post straight to your endpoint.
Start with normalization, since every lookup depends on it:
export function domainOf(email: string): string {
const at = email.lastIndexOf('@');
if (at < 0) return '';
return email.slice(at + 1).trim().toLowerCase().replace(/\.$/, '');
}
For hosts like mail.example.co.uk you need public-suffix-aware matching, not a naive
split on the last two labels. Use a public suffix list library.
Then wrap the verdict in one function called from every entry point: web signup, mobile API, invite acceptance, checkout, SSO first login, admin CSV import. A gate that only exists on the signup form is a speed bump on one of five doors.
Vendor the blocklist and refresh it on a schedule
The reference list is the community disposable-email-domains repository, which publishes
disposable_email_blocklist.conf as one domain per line. PyPI uses it alongside an
internal list to keep throwaway registrations out. The maintainers are honest that they
cannot guarantee every entry is still disposable, which is why you review each diff.
Pull it in CI, never on the request path:
curl -fsSL https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/main/disposable_email_blocklist.conf \
-o data/disposable_email_blocklist.conf
git diff --stat data/disposable_email_blocklist.conf
Load it into a Set at boot. A weekly job that opens a pull request keeps it fresh without the outage risk: fetch inline, and one network hiccup takes your signup page
down with it.
The unglamorous half of how to block disposable email addresses is operating this list after launch. If you would rather a vendor owned it, choosing an email validation API covers what you are really buying.
Add one DNS lookup for the domains no list has seen
dig +short MX example.com
Three answers matter. A single MX with preference 0 and a target of . is a null MX
under RFC 7505: the operator has declared that the domain accepts no mail, so reject it
immediately. No MX and no A or AAAA record means nothing can accept mail there, which in
practice is a typo, so offer a correction instead of a ban. An MX host shared across
hundreds of unrelated domains is the strongest live signal you get, because disposable
providers rotate domain names far faster than the servers behind them.
Two rules keep this safe: cache the result per domain, and fail open on timeout. Never reject a signup because a resolver was slow.
Allowlist on purpose, and check it first
Put your staging domains, your automated test domains, and the large forwarding providers your customers actually use into an allowlist that is consulted before the blocklist, in version control rather than improvised at 2am.
Providers that publish their own pool make this deliberate. InboxDome lists its domains at
GET /v1/domains and exposes the same thing to agents as list_domains, one of the seven
tools on its MCP server, so a site that does not want test traffic can filter it exactly.
Choose the response, then log every block
Return a specific error: a 422 with a machine-readable code such as disposable_domain,
copy that admits this is a policy decision, and a way to reach a human. Anyone told “invalid email
address” about an address that works perfectly well knows what that costs you.
Then log the domain, the verdict, the signal that fired, and whether the person came back with a different address. Watch that last number: a healthy gate shows abusers giving up, a broken one shows real customers switching to a Gmail account they barely read.
Test the gate, and test the mail it depends on
Start with a fixture table of unit tests: a listed domain, a subdomain of one, a null MX domain, a domain with no records, an uppercase address, a plus-addressed one, an allowlisted test domain, and a real address that must pass. They run in milliseconds and catch the normalization bugs that quietly make a gate pass everything.
Then test the flow the gate protects, end to end, with a real inbox:
curl -X POST https://inboxdome.com/v1/inboxes \
-H "Authorization: Bearer $INBOXDOME_KEY"
curl -X POST https://inboxdome.com/v1/inboxes/$INBOX_ID/assert \
-H "Authorization: Bearer $INBOXDOME_KEY" \
-H "Content-Type: application/json" \
-d '{"timeoutSeconds":45,"assertions":[
{"type":"otpPresent"},
{"type":"auth","check":"dkim"}]}'
The Email Testing API for signup and verification flows does the waiting and the assertion in one call, with a free tier of 100 inbox tests a month. Assert on authentication while you are in there, because a signup gate is pointless if the confirmation mail it depends on lands in spam, and SPF, DKIM and DMARC explained covers what each result means when one of them fails.
Whatever you decide about how to block disposable email addresses, blocking is not a fraud strategy on its own, just one cheap input to one. Rate limits, payment verification and confirmed addresses do the heavy lifting, and none of them lock out the customer who simply prefers an alias.
Disclosure: InboxDome publishes this blog and makes the products it mentions. We describe what they do rather than promise results.
Key takeaways
- Block the action, not the account: gate refunds, credit and posting behind a confirmed address instead of rejecting at the form.
- Put the check in one server-side function that every entry point calls, because a gate on the signup form alone is not a gate.
- Vendor the blocklist file into your repo and refresh it on a schedule. Never fetch a list over the network on the signup path.
- One MX lookup catches what no list carries yet, including null MX domains under RFC 7505. Fail open when DNS times out.
- Log every block with the signal that fired, or you cannot tell a working gate from one quietly rejecting real customers.
Sources
- disposable-email-domains blocklist (GitHub) — Publishes disposable_email_blocklist.conf, one domain per line. PyPI uses it alongside an internal list, and the maintainers state they cannot guarantee every entry is still disposable.
- RFC 7505: A Null MX No Service Resource Record — Defines the single MX with preference 0 and a target of ".", the explicit way a domain declares that it accepts no mail.
- MDN: the email input type — States plainly that HTML form validation is not a substitute for server-side checks, because anyone can edit the markup or post directly.
Links last checked September 12, 2026.
Frequently asked questions
Is a blocklist enough on its own?
No. New throwaway domains appear before any list carries them, and a custom domain never appears at all. Treat a list hit as one signal alongside DNS, signup behaviour and rate limits, and reserve hard rejections for actions that cost you money.
Should I block alias and forwarding services too?
Usually not. Alias services are used by ordinary privacy-conscious people who read their mail every day, and lists sometimes sweep them in beside genuine disposables. Allowlist the large ones deliberately and decide per action rather than banning the whole category.
What HTTP status should the API return when the gate fires?
A 422 with a specific machine-readable code such as disposable_domain, plus copy that says it was a policy decision and how to reach support. A generic "invalid email address" sends real users into a loop retyping an address that works fine.
Will this gate block my own automated tests?
Yes, if your tests use a shared temporary-mail pool, since those domains are exactly what the blocklist contains. Allowlist your testing domains outside production and keep the allowlist checked before the blocklist.