is-this-mail-fake
v1.0.0
Published
Detect fake, disposable, and temporary email addresses. Zero dependencies. 500+ domains built-in.
Downloads
39
Maintainers
Readme
is-this-mail-fake 🚫
Detect fake, disposable, and temporary email addresses instantly. 670+ domains built-in. Zero dependencies. Works in Node + Browser.
Install
npm install is-this-mail-fakeQuick Start
import { isFake, isReal } from 'is-this-mail-fake';
isFake('[email protected]') // true
isFake('[email protected]') // true
isFake('[email protected]') // true
isFake('[email protected]') // false
isFake('[email protected]') // falseAPI
isFake(email) → boolean
Returns true if the email uses a disposable/fake provider.
import { isFake } from 'is-this-mail-fake';
isFake('[email protected]') // true
isFake('[email protected]')// true
isFake('[email protected]') // false
isFake('invalid-email') // false (invalid = not fake)
isFake(null) // false (safe — no crash)isReal(email) → boolean
Opposite of isFake. Returns true if email looks legitimate.
import { isReal } from 'is-this-mail-fake';
isReal('[email protected]') // true
isReal('[email protected]') // falsecheck(email) → object
Full result with domain and reason.
import { check } from 'is-this-mail-fake';
check('[email protected]')
// {
// email: '[email protected]',
// domain: 'mailinator.com',
// fake: true,
// reason: 'disposable'
// }
check('[email protected]')
// { email: '[email protected]', domain: 'gmail.com', fake: false, reason: 'clean' }
check('not-an-email')
// { email: 'not-an-email', domain: null, fake: false, reason: 'invalid_email' }Reasons:
| Reason | Meaning |
|---|---|
| disposable | Domain is in the built-in blocklist |
| disposable_subdomain | Subdomain of a known disposable provider |
| blacklisted | In your custom blacklist |
| whitelisted | In your custom whitelist — trusted |
| clean | Not found in any list |
| invalid_email | Not a valid email format |
checkMany(emails[]) → object[]
Check multiple emails at once.
import { checkMany } from 'is-this-mail-fake';
checkMany(['[email protected]', '[email protected]', '[email protected]'])
// [
// { email: '[email protected]', fake: false, reason: 'clean' },
// { email: '[email protected]', fake: true, reason: 'disposable' },
// { email: '[email protected]', fake: true, reason: 'disposable' },
// ]filterReal(emails[]) → string[]
Keep only real emails from a list.
import { filterReal } from 'is-this-mail-fake';
filterReal(['[email protected]', '[email protected]', '[email protected]'])
// ['[email protected]', '[email protected]']filterFake(emails[]) → string[]
Keep only fake emails from a list.
import { filterFake } from 'is-this-mail-fake';
filterFake(['[email protected]', '[email protected]', '[email protected]'])
// ['[email protected]', '[email protected]']isFakeDomain(domain) → boolean
Check a domain directly without a full email.
import { isFakeDomain } from 'is-this-mail-fake';
isFakeDomain('mailinator.com') // true
isFakeDomain('gmail.com') // falseblacklist(domain | domain[]) — Custom blocklist
Add your own domains to always treat as fake.
import { blacklist, isFake } from 'is-this-mail-fake';
blacklist('internal-test.xyz');
blacklist(['disposable.io', 'temp-users.co']);
isFake('[email protected]') // truewhitelist(domain | domain[]) — Custom allowlist
Trust specific domains — always bypass all checks.
import { whitelist, isReal } from 'is-this-mail-fake';
// Your own org domains
whitelist('enrole.ai');
whitelist(['growbharatbiz.com', 'logixbuilt.com']);
isReal('[email protected]') // true (even if it ever appeared in a list)Unknown domains are always treated as real. Only domains explicitly in the built-in blocklist are flagged. Use
whitelist()to guarantee your org domains are never blocked.
getLists() — See custom lists
import { getLists } from 'is-this-mail-fake';
getLists()
// { blacklist: ['internal-test.xyz'], whitelist: ['enrole.ai'] }domainCount() → number
Total domains in built-in blocklist.
import { domainCount } from 'is-this-mail-fake';
domainCount() // 670CLI
# Single email
npx is-this-mail-fake [email protected]
# Multiple emails at once
npx is-this-mail-fake [email protected] [email protected] [email protected]
# JSON output
npx is-this-mail-fake [email protected] --jsonOutput:
✗ FAKE [email protected] (disposable)
✓ REAL [email protected]
✗ FAKE [email protected] (disposable)Exit code 1 if any email is fake — useful for CI/scripts.
Common Use Cases
Signup form validation (Node.js)
import { isFake } from 'is-this-mail-fake';
app.post('/register', (req, res) => {
const { email } = req.body;
if (isFake(email)) {
return res.status(400).json({
error: 'Disposable email addresses are not allowed. Please use a real email.'
});
}
// proceed with registration...
});NestJS / class-validator pipe
import { isFake } from 'is-this-mail-fake';
import { registerDecorator } from 'class-validator';
export function IsNotFakeEmail() {
return registerDecorator({
name: 'isNotFakeEmail',
validator: {
validate: (email: string) => !isFake(email),
defaultMessage: () => 'Disposable email addresses are not allowed',
},
});
}
// Usage in DTO:
class RegisterDto {
@IsEmail()
@IsNotFakeEmail()
email: string;
}React form validation
import { isFake } from 'is-this-mail-fake';
function EmailInput({ value, onChange }) {
const fake = value && isFake(value);
return (
<div>
<input value={value} onChange={e => onChange(e.target.value)} />
{fake && <p style={{ color: 'red' }}>Disposable emails are not allowed</p>}
</div>
);
}Clean a mailing list
import { filterReal, checkMany } from 'is-this-mail-fake';
const emailList = ['[email protected]', '[email protected]', '[email protected]', '[email protected]'];
// Keep only real
const clean = filterReal(emailList);
// ['[email protected]', '[email protected]']
// Get details on all
const report = checkMany(emailList);
const fakeCount = report.filter(r => r.fake).length;
console.log(`Removed ${fakeCount} disposable emails`);CI — block fake emails in tests
# In your CI pipeline
npx is-this-mail-fake $TEST_EMAIL
# exits 1 if fake — fails the pipelineHow It Works
- Extracts the domain from the email (
[email protected]→mailinator.com) - Custom whitelist check — whitelisted domains always pass (your org domains)
- Custom blacklist check — your own blocked domains
- Built-in list lookup — O(1) Set lookup against 670+ known disposable domains
- Wildcard match — catches subdomains like
bob.mailinator.com
All lookups are in-memory and synchronous — no network calls, no async, no latency.
License
MIT © Adarsh
Contributing
PRs welcome! To add more domains, edit src/domains.js.
