disposable-emails
Fast, zero-allocation disposable / temporary email domain detection for Rust.
Tells you whether an email address — or just its domain — belongs to a disposable / temp-mail provider (Mailinator, Guerrilla Mail, 10MinuteMail, and ~72,000 others). Useful for blocking throwaway inboxes from sign-up flows, free-trial farming, and per-account abuse.
[]
= "0.1"
use ;
assert!;
assert!;
assert!;
Why it's cheap
The ~72k-domain blocklist is compiled into a sorted &'static [&'static str]
by the build script. There is:
- no heap allocation — the list lives in the binary's read-only segment;
no
HashSetis built, - no startup cost — nothing is parsed or loaded at runtime,
- an
O(log n)binary-search lookup (~17 comparisons).
The only per-call allocation is a small lowercase copy of the input domain.
API
| Function | Description |
|---|---|
is_disposable_email(&str) -> bool |
Domain of the address is disposable. Malformed input → false. |
is_disposable_domain(&str) -> bool |
The domain is disposable. Case-insensitive; tolerates a trailing .. |
domain_count() -> usize |
Size of the embedded blocklist. |
The blocklist
domains.txt is a vendored copy of the community-maintained
disposable
aggregate. To refresh it, replace that file and rebuild — the build script
re-sorts and de-duplicates.
no_std is not required to be off — the crate is #![forbid(unsafe_code)] and
depends only on core/alloc-level std.
Licence
Dual-licensed under either of Apache-2.0 or MIT, at your option.