email-verifier-check
v1.3.0
Published
A simple, zero-dependency email verification library with format validation, DNS checking, and SMTP probing
Maintainers
Readme
Email Verifier
A simple, zero-runtime-dependency email verification library for Node.js. Verify email addresses through format validation, DNS checking, and SMTP probing.
Features
- Format Validation - RFC 5322 compliant email format checking
- DNS Verification - MX record lookup with A record fallback
- SMTP Probing - RCPT TO verification without sending email
- Catch-all Detection - Identifies domains that accept any email
- Provider Detection - Identifies mail providers (Google, Microsoft, etc.)
- Caching - Built-in caching for performance
- Rate Limiting - Token bucket throttling with exponential backoff
- Zero Dependencies - Uses only Node.js built-ins at runtime
Installation
npm install email-verifier-checkCLI Usage
# Verify a single email
npx email-verifier-check check [email protected]
# Verify multiple emails
npx email-verifier-check check [email protected] [email protected]
# Output as JSON
npx email-verifier-check check [email protected] --json
# Skip SMTP check (faster, less accurate)
npx email-verifier-check check [email protected] --no-smtp
# Skip catch-all detection
npx email-verifier-check check [email protected] --no-catchallProgrammatic Usage
import { verifyEmail, verifyEmails } from "email-verifier-check";
// Verify a single email
const result = await verifyEmail("[email protected]");
console.log(result);
// {
// email: '[email protected]',
// valid: true,
// confidence: 0.95,
// details: {
// formatValid: true,
// mxRecords: ['aspmx.l.google.com'],
// smtpStatus: 'accepted',
// catchAll: false,
// provider: {
// name: 'Google Workspace',
// url: 'https://workspace.google.com'
// }
// }
// }
// Verify multiple emails
const results = await verifyEmails(["[email protected]", "[email protected]"]);Options
interface VerifyOptions {
// Timeout for DNS lookups in milliseconds (default: 5000)
dnsTimeout?: number;
// Timeout for SMTP connections in milliseconds (default: 10000)
smtpTimeout?: number;
// Whether to perform SMTP verification (default: true)
smtpCheck?: boolean;
// Whether to perform catch-all detection (default: true)
catchAllCheck?: boolean;
// The sender email to use in SMTP MAIL FROM (default: [email protected])
senderEmail?: string;
// SMTP port to connect to (default: 25)
smtpPort?: number;
}
// Example with options
const result = await verifyEmail("[email protected]", {
smtpTimeout: 15000,
catchAllCheck: false,
});Understanding Results
Confidence Scores
| Scenario | Valid | Confidence | Meaning |
| ------------------------ | ------- | ---------- | ----------------------------- |
| Invalid format | false | 0% | Email syntax is invalid |
| No DNS records | false | 0% | Domain cannot receive email |
| SMTP rejected (5xx) | false | 0% | Mailbox doesn't exist |
| SMTP timeout/error | true | 50% | Could be valid, can't confirm |
| Accepted + catch-all | true | 60% | Domain accepts any email |
| Accepted + NOT catch-all | true | 95% | High confidence valid |
SMTP Status Values
accepted- Server returned 2xx to RCPT TOrejected- Server returned 5xx to RCPT TOunknown- Server returned 4xx or connection failedskipped- SMTP check was not performed
Supported Mail Providers
The library automatically detects these mail providers from MX records:
- Google Workspace
- Microsoft 365
- Proofpoint / Proofpoint Essentials
- Mimecast
- Yahoo Mail
- Zoho Mail
- Fastmail
- Proton Mail
- iCloud Mail
- Amazon SES
- SendGrid
- Mailgun
- Postmark
- And more...
How It Works
Verification Pipeline
- Format Check - Validates email against RFC 5322 pattern
- DNS Check - Queries MX records, falls back to A record per RFC 5321
- SMTP Probe - Connects to mail server and tests with
RCPT TO - Catch-all Detection - Tests with fake
x9x0{localpart}@domain
Rate Limiting
The library includes built-in rate limiting to avoid overwhelming mail servers:
- Token bucket algorithm (10 requests per host, 1/second refill)
- Exponential backoff on failures (5s initial, 5min max)
- Automatic recovery after successful requests
Development
# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Build
npm run build
# Type check
npm run lintLicense
MIT
