A brutally honest, no-bullshit TypeScript email validation library that doesn’t just check if your email looks legit — it actually checks if the damn thing can receive mail.
This isn’t some cute regex-only toy. This shit goes all the way: DNS, MX, SMTP handshake — the whole fucking pipeline.
- ✅ Syntax Validation – RFC-style format checks. No stupid
a@bgarbage. - 🚫 Disposable Email Detection – Blocks fake/temp inbox bullshit using
fakefilter. - 🌐 DNS MX Verification – Checks if the domain even has mail servers configured.
- 📬 SMTP Deliverability Test – Talks directly to the mail server like, “yo, does this user exist?”
- ⚡ Smart Provider Handling – Skips SMTP for big boys like Yahoo, Outlook, Hotmail, AOL, and iCloud because they block verification and don’t give a shit.
- 🎛️ Configurable as Hell – Turn checks on/off depending on how paranoid you are.
- 🔒 TypeScript Native – Proper types. No
anynonsense. Powered by TypeScript.
Install it like a civilized engineer:
npm install @ejekanshjain/simple-email-validatorOr if you’re fancy:
pnpm install @ejekanshjain/simple-email-validatorOr living that fast life:
bun install @ejekanshjain/simple-email-validatorimport { validateEmail } from '@ejekanshjain/simple-email-validator'
const result = await validateEmail({ email: 'user@example.com' })
if (result.isValid === true) {
console.log('✓ This email is legit as fuck')
} else if (result.isValid === false) {
console.log(`✗ Nope. Broken shit: ${result.status}`)
} else {
console.log(`⚠ Could not verify. Server being shady: ${result.status}`)
}This library doesn’t half-ass validation. It goes step by step:
Regex-based validation:
- No starting with a dot like
.idiot@example.com - No consecutive dots
- Proper TLD (at least 2 characters)
- Only valid characters allowed
If it fails here, it’s dead. End of story.
Uses fakefilter to detect trash providers.
If someone signs up with tempmail-123@randomshit.com, we shut that down instantly.
We query DNS for MX records.
No MX? That domain is basically a corpse.
Big providers like Gmail and others don’t like being pinged.
So instead of giving you false negatives and random bullshit failures, we skip SMTP verification for them.
Smart. Not reckless.
This is where shit gets real.
- Connect to port 25
- HELO
- MAIL FROM
- RCPT TO
- Interpret server response
If the server says:
- “User unknown” → it’s dead.
- Temporary error → we return
null. - Accepts recipient → deliverable (unless catch-all).
This is as close as you get without actually sending an email.
{
email: string
timeoutMs?: number
regexCheck?: boolean
fakeEmailCheck?: boolean
}Returns:
Promise<ValidationResult>interface ValidationResult {
isValid: boolean | null
status: string
reason?: string
mxRecord?: string
}true→ This email is good to go.false→ Absolutely broken.null→ Couldn’t verify. Server said “nah” or timed out.
| Status | isValid | What It Means |
|---|---|---|
| Deliverable | true | Email is solid |
| Invalid Syntax | false | Format is garbage |
| Disposable Email Detected | false | Fake/temp inbox |
| No MX Records (Domain Dead) | false | Domain has no mail server |
| User Unknown | false | Address doesn’t exist |
| Skipped SMTP (Provider blocks pings) | null | Big provider blocking |
| Timeout | null | Server too slow |
| Connection Error | null | Couldn’t connect |
| Server Reject (Greylist/Spam) | null | Server didn’t like us |
Big providers block SMTP verification. Greylisting exists. Anti-spam filters exist.
Sometimes you’ll get null. That’s life.
Catch-all servers exist. Some mail servers accept everything and bounce later.
So yeah, no validator on Earth is 100% perfect.
You’re opening real SMTP connections.
Spam this aggressively and you might:
- Hit rate limits
- Get blocked
- Get your IP blacklisted
So chill the fuck out and cache results.
Full validation can take 1–5 seconds.
DNS + SMTP isn’t instant magic.
If you need speed:
- Skip SMTP
- Run async
- Batch process
This library does not throw random-ass exceptions.
Everything is returned cleanly inside ValidationResult.
Example:
await validateEmail({ email: 'not-an-email' })
// { isValid: false, status: 'Invalid Syntax' }No crashes. No drama. Just structured results.
MIT © Ekansh Jain
Do whatever you want with it. Just don’t blame the library when some weird mail server behaves like a diva.
PRs welcome.
But please:
- Don’t submit half-baked garbage.
- Write tests.
- Don’t break existing behavior.
https://github.com/ejekanshjain/simple-email-validator
If you’re tired of fake signups, trash leads, and garbage email validation logic…
Use this.
Validate like a savage.