
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@devmehq/email-validator-js
Advanced tools
Advanced email validation with MX records, SMTP verification, disposable email detection, batch processing, and caching. Production-ready with TypeScript support.
๐ Advanced email validation library for Node.js with MX record checking, SMTP verification, disposable email detection, and much more. Now with batch processing, advanced caching, and detailed error reporting.
โ Check email address validity
โ Check email address domain validity in domain TLD list
โ Check email address MX records
โ Check email address SMTP connection
โ Check email address disposable or burnable status
โ Check email address free email provider status
โ NEW: Batch email verification with concurrency control
โ NEW: Detailed verification results with error codes
โ NEW: Built-in caching for improved performance
โ NEW: Automatic retry mechanism for transient failures
โ NEW: RFC 5321 compliant validation
โ NEW: Enhanced name detection from email addresses with composite name support
โ NEW: Domain typo detection and suggestions with caching
โ NEW: Get domain age via WHOIS lookup
โ NEW: Get domain registration status via WHOIS lookup
โ NEW: Serverless support for AWS Lambda, Vercel Edge, Cloudflare Workers, and more
We offer this email verification and validation and more advanced features
in our Scalable Cloud API Service Offering - You could try it here Email Verification
email-validator-js is licensed under Business Source License 1.1.
Use Case | Is a commercial license required? |
---|---|
Exploring email-validator-js for your own research, hobbies, and testing purposes | No |
Using email-validator-js to build a proof-of-concept application | No |
Using email-validator-js to build revenue-generating applications | Yes |
Using email-validator-js to build software that is provided as a service (SaaS) | Yes |
Forking email-validator-js for any production purposes | Yes |
๐ For commercial licensing, visit dev.me/license/email-validator or contact us at sales@dev.me.
Install the module through Yarn:
yarn add @devmehq/email-validator-js
Or NPM:
npm install @devmehq/email-validator-js
import { verifyEmail } from '@devmehq/email-validator-js';
// Basic usage
const result = await verifyEmail({
emailAddress: 'user@example.com',
verifyMx: true,
verifySmtp: true,
timeout: 3000
});
console.log(result.validFormat); // true
console.log(result.validMx); // true
console.log(result.validSmtp); // true or false
verifyEmail(params: IVerifyEmailParams): Promise<IVerifyEmailResult>
Basic email verification with backward compatibility.
Parameters:
emailAddress
(string, required): Email address to verifytimeout
(number): Timeout in milliseconds (default: 4000)verifyMx
(boolean): Check MX records (default: false)verifySmtp
(boolean): Verify SMTP connection (default: false)smtpPort
(number): Custom SMTP portdebug
(boolean): Enable debug logging (default: false)detectName
(boolean): Detect names from email address (default: false)nameDetectionMethod
(function): Custom name detection methodsuggestDomain
(boolean): Enable domain typo suggestions (default: false)domainSuggestionMethod
(function): Custom domain suggestion methodcommonDomains
(string[]): Custom list of domains for suggestionsReturns:
{
validFormat: boolean;
validMx: boolean | null;
validSmtp: boolean | null;
detectedName?: DetectedName | null;
domainSuggestion?: DomainSuggestion | null;
}
verifyEmailDetailed(params: IVerifyEmailParams): Promise<DetailedVerificationResult>
Advanced verification with detailed results and error codes.
Additional Parameters:
checkDisposable
(boolean): Check for disposable emails (default: true)checkFree
(boolean): Check for free email providers (default: true)retryAttempts
(number): Retry attempts for failures (default: 1)detectName
(boolean): Detect names from email address (default: false)suggestDomain
(boolean): Enable domain typo suggestions (default: true in detailed mode)Returns:
{
valid: boolean;
email: string;
format: {
valid: boolean;
error?: VerificationErrorCode;
};
domain: {
valid: boolean | null;
mxRecords?: string[];
error?: VerificationErrorCode;
};
smtp: {
valid: boolean | null;
error?: VerificationErrorCode;
};
disposable: boolean;
freeProvider: boolean;
detectedName?: DetectedName | null;
domainSuggestion?: DomainSuggestion | null;
metadata?: {
verificationTime: number;
cached: boolean;
};
}
verifyEmailBatch(params: IBatchVerifyParams): Promise<BatchVerificationResult>
Verify multiple emails in parallel with concurrency control.
Parameters:
emailAddresses
(string[], required): Array of emails to verifyconcurrency
(number): Parallel processing limit (default: 5)detailed
(boolean): Return detailed results (default: false)detectName
(boolean): Detect names from email addressessuggestDomain
(boolean): Enable domain typo suggestionsverifyEmail
Returns:
{
results: Map<string, DetailedVerificationResult | IVerifyEmailResult>;
summary: {
total: number;
valid: number;
invalid: number;
errors: number;
processingTime: number;
};
}
detectName(email: string): DetectedName | null
Detect first and last name from email address.
const name = detectName('john.doe@example.com');
// Returns: { firstName: 'John', lastName: 'Doe', confidence: 0.9 }
Detection Patterns:
john.doe
โ John Doe (90% confidence)jane_smith
โ Jane Smith (80% confidence)mary-johnson
โ Mary Johnson (80% confidence)johnDoe
โ John Doe (70% confidence)mo1.test2
โ Mo1 Test2 (60% confidence)user1.admin2
โ User1 Admin2 (60% confidence)john.doe123
โ John Doe (80% confidence)john.doe.dev
โ John Doe (70% confidence)alice
โ Alice (50% confidence)Enhanced Features:
detectNameFromEmail(params: IDetectNameParams): DetectedName | null
Advanced name detection with custom method support.
const customMethod = (email: string) => {
// Your custom logic
return { firstName: 'Custom', lastName: 'Name', confidence: 1.0 };
};
const name = detectNameFromEmail({
email: 'user@example.com',
customMethod: customMethod
});
Parameters:
email
(string): Email addresscustomMethod
(function): Custom detection logicdefaultNameDetectionMethod(email: string): DetectedName | null
The default name detection implementation, exported for custom extensions.
suggestEmailDomain(email: string, commonDomains?: string[]): DomainSuggestion | null
Detect and suggest corrections for misspelled email domains.
const suggestion = suggestEmailDomain('user@gmial.com');
// Returns: { original: 'user@gmial.com', suggested: 'user@gmail.com', confidence: 0.95 }
// With custom domain list
const customDomains = ['company.com', 'enterprise.org'];
const customSuggestion = suggestEmailDomain('user@compny.com', customDomains);
Features:
suggestDomain(params: ISuggestDomainParams): DomainSuggestion | null
Advanced domain suggestion with custom method support.
const suggestion = suggestDomain({
domain: 'gmial.com',
customMethod: myCustomMethod,
commonDomains: ['company.com']
});
Parameters:
domain
(string): Domain to checkcustomMethod
(function): Custom suggestion logiccommonDomains
(string[]): Custom domain listdefaultDomainSuggestionMethod(domain: string, commonDomains?: string[]): DomainSuggestion | null
The default domain suggestion implementation, exported for custom extensions.
isCommonDomain(domain: string, commonDomains?: string[]): boolean
Check if a domain is in the common domains list.
isCommonDomain('gmail.com'); // true
isCommonDomain('mycompany.com'); // false
// With custom list
isCommonDomain('mycompany.com', ['mycompany.com']); // true
getDomainSimilarity(domain1: string, domain2: string): number
Calculate similarity score between two domains (0-1).
getDomainSimilarity('gmail.com', 'gmial.com'); // 0.8
getDomainSimilarity('gmail.com', 'yahoo.com'); // 0.3
Note: WHOIS functions use PSL (Public Suffix List) validation to ensure domain validity before performing lookups. Invalid domains or domains without valid TLDs will return
null
.
getDomainAge(domain: string, timeout?: number): Promise<DomainAgeInfo | null>
Get domain age information via WHOIS lookup.
const ageInfo = await getDomainAge('example.com');
// Returns:
// {
// domain: 'example.com',
// creationDate: Date,
// ageInDays: 7890,
// ageInYears: 21.6,
// expirationDate: Date,
// updatedDate: Date
// }
// Works with email addresses and URLs too
await getDomainAge('user@example.com');
await getDomainAge('https://example.com/path');
Parameters:
domain
(string): Domain, email, or URL to checktimeout
(number): Timeout in milliseconds (default: 5000)Returns: DomainAgeInfo
object or null
if lookup fails
getDomainRegistrationStatus(domain: string, timeout?: number): Promise<DomainRegistrationInfo | null>
Get detailed domain registration status via WHOIS.
const status = await getDomainRegistrationStatus('example.com');
// Returns:
// {
// domain: 'example.com',
// isRegistered: true,
// isAvailable: false,
// status: ['clientTransferProhibited'],
// registrar: 'Example Registrar',
// nameServers: ['ns1.example.com', 'ns2.example.com'],
// expirationDate: Date,
// isExpired: false,
// daysUntilExpiration: 365,
// isPendingDelete: false,
// isLocked: true
// }
Parameters:
domain
(string): Domain, email, or URL to checktimeout
(number): Timeout in milliseconds (default: 5000)Returns: DomainRegistrationInfo
object or null
if lookup fails
Features:
isDisposableEmail(emailOrDomain: string): boolean
Check if email uses a disposable provider.
isDisposableEmail('user@tempmail.com'); // true
isDisposableEmail('tempmail.com'); // true
isDisposableEmail('gmail.com'); // false
isFreeEmail(emailOrDomain: string): boolean
Check if email uses a free provider.
isFreeEmail('user@gmail.com'); // true
isFreeEmail('yahoo.com'); // true
isFreeEmail('corporate.com'); // false
isValidEmail(emailAddress: string): boolean
Validate email format (RFC 5321 compliant).
isValidEmail('user@example.com'); // true
isValidEmail('invalid.email'); // false
Validation Rules:
isValidEmailDomain(emailOrDomain: string): boolean
Validate if a domain has a valid TLD.
isValidEmailDomain('example.com'); // true
isValidEmailDomain('example.invalid'); // false
clearAllCaches(): void
Clear all internal caches (including domain suggestions).
clearAllCaches();
DetectedName
interface DetectedName {
firstName?: string;
lastName?: string;
confidence: number; // 0-1 scale
}
DomainSuggestion
interface DomainSuggestion {
original: string;
suggested: string;
confidence: number; // 0-1 scale
}
NameDetectionMethod
type NameDetectionMethod = (email: string) => DetectedName | null;
DomainSuggestionMethod
type DomainSuggestionMethod = (domain: string) => DomainSuggestion | null;
DomainAgeInfo
interface DomainAgeInfo {
domain: string;
creationDate: Date;
ageInDays: number;
ageInYears: number;
expirationDate: Date | null;
updatedDate: Date | null;
}
DomainRegistrationInfo
interface DomainRegistrationInfo {
domain: string;
isRegistered: boolean;
isAvailable: boolean;
status: string[];
registrar: string | null;
nameServers: string[];
expirationDate: Date | null;
isExpired: boolean;
daysUntilExpiration: number | null;
isPendingDelete?: boolean;
isLocked?: boolean;
}
COMMON_EMAIL_DOMAINS
Array of 70+ common email domains used for typo detection.
import { COMMON_EMAIL_DOMAINS } from '@devmehq/email-validator-js';
console.log(COMMON_EMAIL_DOMAINS);
// ['gmail.com', 'yahoo.com', 'outlook.com', 'hotmail.com', ...]
Includes:
enum VerificationErrorCode {
INVALID_FORMAT = 'INVALID_FORMAT',
INVALID_DOMAIN = 'INVALID_DOMAIN',
NO_MX_RECORDS = 'NO_MX_RECORDS',
SMTP_CONNECTION_FAILED = 'SMTP_CONNECTION_FAILED',
SMTP_TIMEOUT = 'SMTP_TIMEOUT',
MAILBOX_NOT_FOUND = 'MAILBOX_NOT_FOUND',
MAILBOX_FULL = 'MAILBOX_FULL',
NETWORK_ERROR = 'NETWORK_ERROR',
DISPOSABLE_EMAIL = 'DISPOSABLE_EMAIL',
FREE_EMAIL_PROVIDER = 'FREE_EMAIL_PROVIDER'
}
timeout
Set a timeout in milliseconds for the smtp connection. Default: 4000
.
verifyMx
Enable or disable domain checking. This is done in two steps:
Default: false
.
verifySmtp
Enable or disable mailbox checking. Only a few SMTP servers allow this, and even then whether it works depends on your IP's reputation with those servers. This library performs a best effort validation:
null
for Yahoo addresses, for failed connections, for unknown SMTP errorstrue
for valid SMTP responsesfalse
for SMTP errors specific to the address's formatting or mailbox existenceDefault: false
.
checkDisposable
(NEW)Check if the email domain is a known disposable email provider. Default: false
.
checkFree
(NEW)Check if the email domain is a known free email provider. Default: false
.
detailed
(NEW)Return detailed verification results with error codes. Default: false
.
retryAttempts
(NEW)Number of retry attempts for transient failures. Default: 1
.
import { verifyEmail } from '@devmehq/email-validator-js';
const { validFormat, validSmtp, validMx } = await verifyEmail({
emailAddress: 'foo@email.com',
verifyMx: true,
verifySmtp: true,
timeout: 3000
});
// validFormat: true
// validMx: true
// validSmtp: true
import { verifyEmailDetailed } from '@devmehq/email-validator-js';
const result = await verifyEmailDetailed({
emailAddress: 'foo@email.com',
verifyMx: true,
verifySmtp: true,
checkDisposable: true,
checkFree: true
});
// result.valid: true
// result.disposable: false
// result.freeProvider: false
// result.domain.mxRecords: ['mx1.email.com', 'mx2.email.com']
// result.metadata.verificationTime: 125
import { verifyEmailBatch } from '@devmehq/email-validator-js';
const emails = ['user1@gmail.com', 'user2@example.com', 'invalid@fake.com'];
const result = await verifyEmailBatch({
emailAddresses: emails,
concurrency: 5,
verifyMx: true,
detailed: true
});
// result.summary.valid: 2
// result.summary.invalid: 1
// result.summary.processingTime: 234
import { detectName, verifyEmailDetailed } from '@devmehq/email-validator-js';
// Standalone name detection - now with composite name support
const name = detectName('john.doe@example.com');
// name: { firstName: 'John', lastName: 'Doe', confidence: 0.9 }
// Handle alphanumeric composite names
const composite = detectName('mo1.test2@example.com');
// composite: { firstName: 'Mo1', lastName: 'Test2', confidence: 0.6 }
// Smart handling of numbers and suffixes
const withNumbers = detectName('john.doe123@example.com');
// withNumbers: { firstName: 'John', lastName: 'Doe', confidence: 0.8 }
const withSuffix = detectName('jane.smith.dev@example.com');
// withSuffix: { firstName: 'Jane', lastName: 'Smith', confidence: 0.7 }
// Integrated with email verification
const result = await verifyEmailDetailed({
emailAddress: 'jane_smith@example.com',
detectName: true
});
// result.detectedName: { firstName: 'Jane', lastName: 'Smith', confidence: 0.8 }
// Custom detection method
const customMethod = (email: string) => {
// Your custom logic here
return { firstName: 'Custom', lastName: 'Name', confidence: 1.0 };
};
const resultCustom = await verifyEmail({
emailAddress: 'user@example.com',
detectName: true,
nameDetectionMethod: customMethod
});
import { suggestEmailDomain, verifyEmailDetailed } from '@devmehq/email-validator-js';
// Standalone domain suggestion
const suggestion = suggestEmailDomain('user@gmial.com');
// suggestion: { original: 'user@gmial.com', suggested: 'user@gmail.com', confidence: 0.95 }
// Integrated with email verification (enabled by default in detailed mode)
const result = await verifyEmailDetailed({
emailAddress: 'john@yaho.com',
suggestDomain: true // Default: true for detailed verification
});
// result.domainSuggestion: { original: 'john@yaho.com', suggested: 'john@yahoo.com', confidence: 0.9 }
// With custom domain list
const customDomains = ['company.com', 'enterprise.org'];
const resultCustom = await verifyEmail({
emailAddress: 'user@compny.com',
suggestDomain: true,
commonDomains: customDomains
});
// resultCustom.domainSuggestion: { suggested: 'user@company.com', confidence: 0.85 }
When a domain does not exist or has no MX records:
const result = await verifyEmail({
emailAddress: 'foo@bad-domain.com',
verifyMx: true,
verifySmtp: true
});
// validFormat: true
// validMx: false
// validSmtp: null (couldn't be performed)
const detailed = await verifyEmailDetailed({
emailAddress: 'user@suspicious-domain.com',
verifyMx: true,
verifySmtp: true,
checkDisposable: true,
checkFree: true
});
if (!detailed.valid) {
switch (detailed.domain.error) {
case VerificationErrorCode.DISPOSABLE_EMAIL:
console.log('Rejected: Disposable email');
break;
case VerificationErrorCode.NO_MX_RECORDS:
console.log('Rejected: Invalid domain');
break;
case VerificationErrorCode.MAILBOX_NOT_FOUND:
console.log('Rejected: Mailbox does not exist');
break;
}
}
const emails = [
'valid@gmail.com',
'test@tempmail.com',
'user@company.com',
// ... hundreds more
];
const batch = await verifyEmailBatch({
emailAddresses: emails,
concurrency: 10, // Process 10 emails simultaneously
verifyMx: true,
checkDisposable: true,
detailed: true
});
console.log(`Processed ${batch.summary.total} emails`);
console.log(`Valid: ${batch.summary.valid}`);
console.log(`Invalid: ${batch.summary.invalid}`);
console.log(`Time: ${batch.summary.processingTime}ms`);
// Filter out invalid emails
const validEmails = [];
for (const [email, result] of batch.results) {
if (result.valid) {
validEmails.push(email);
}
}
// First verification - hits DNS and SMTP
const first = await verifyEmail({
emailAddress: 'cached@example.com',
verifyMx: true
});
// Takes ~500ms
// Second verification - uses cache
const second = await verifyEmail({
emailAddress: 'cached@example.com',
verifyMx: true
});
// Takes ~1ms (cached)
// Clear cache if needed
clearAllCaches();
Note: Yahoo, Hotmail, and some providers always return validSmtp: true
as they don't allow mailbox verification.
The package includes serverless adapters for major cloud platforms. The serverless implementation provides email validation without Node.js dependencies, making it suitable for edge computing environments.
import { apiGatewayHandler } from '@devmehq/email-validator-js/serverless/aws';
export const handler = apiGatewayHandler;
import { edgeHandler } from '@devmehq/email-validator-js/serverless/vercel';
export const config = {
runtime: 'edge',
};
export default edgeHandler;
import { workerHandler } from '@devmehq/email-validator-js/serverless/cloudflare';
export default {
async fetch(request, env, ctx) {
return workerHandler(request, env, ctx);
},
};
For detailed serverless documentation and more platform examples, see docs/SERVERLESS.md.
The library includes intelligent caching to improve performance:
Cache Type | TTL | Description |
---|---|---|
MX Records | 1 hour | DNS MX record lookups |
Disposable | 24 hours | Disposable email checks |
Free Provider | 24 hours | Free email provider checks |
Domain Valid | 24 hours | Domain validation results |
SMTP | 30 minutes | SMTP verification results |
Domain Suggestions | 24 hours | Domain typo suggestions |
verifyEmailBatch()
for parallel processingView List - 5,000+ disposable email domains
View List - 1,000+ free email providers
Access the list of 70+ common email domains used for typo detection:
import { COMMON_EMAIL_DOMAINS } from '@devmehq/email-validator-js';
console.log(COMMON_EMAIL_DOMAINS);
// ['gmail.com', 'yahoo.com', 'outlook.com', 'hotmail.com', ...]
// Use with your own domain validation
const isCommon = COMMON_EMAIL_DOMAINS.includes('gmail.com'); // true
Run the test suite:
yarn test
Run with coverage:
yarn test --coverage
Lint the code:
yarn lint
yarn lint-fix # Auto-fix issues
Build the project:
yarn build
email-validator-js/
โโโ src/ # Source code
โ โโโ index.ts # Main entry point
โ โโโ smtp.ts # SMTP verification
โ โโโ dns.ts # DNS/MX lookups
โ โโโ validator.ts # Format validation
โ โโโ cache.ts # Caching system
โ โโโ batch.ts # Batch processing
โ โโโ types.ts # TypeScript types
โโโ __tests__/ # Test files
โโโ examples/ # Usage examples
โโโ dist/ # Compiled output
yarn build # Build TypeScript with Rollup
yarn test # Run tests with Jest
yarn lint # Run ESLint
yarn lint-fix # Fix ESLint issues
yarn typecheck # Run TypeScript type checking
We welcome contributions! Please feel free to open an issue or create a pull request and fix bugs or add features. All contributions are welcome!
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)# Clone the repo
git clone https://github.com/devmehq/email-validator-js.git
cd email-validator-js
# Install dependencies
yarn install
# Run tests
yarn test
# Build
yarn build
For issues, questions, or commercial licensing:
๐ Open an Issue ๐ง Email Support ๐ Commercial License ๐ Visit Dev.me
Business Source License 1.1 - see LICENSE file for details.
The BSL allows use only for non-production purposes. Here's a comprehensive guide to help you understand when you need a commercial license:
Use Case | Commercial License Required? | Details |
---|---|---|
Personal & Learning | ||
๐ฌ Exploring email-validator-js for research or learning | โ No | Use freely for educational purposes |
๐จ Personal hobby projects (non-commercial) | โ No | Build personal tools and experiments |
๐งช Testing and evaluation in development environment | โ No | Test all features before purchasing |
Development & Prototyping | ||
๐ก Building proof-of-concept applications | โ No | Create demos and prototypes |
๐ ๏ธ Internal tools (not customer-facing) | โ No | Use for internal development tools |
๐ Open source projects (non-commercial) | โ No | Contribute to the community |
Commercial & Production Use | ||
๐ฐ Revenue-generating applications | โ Yes | Any app that generates income |
โ๏ธ Software as a Service (SaaS) products | โ Yes | Cloud-based service offerings |
๐ฆ Distributed commercial software | โ Yes | Software sold to customers |
๐ข Enterprise production systems | โ Yes | Business-critical applications |
๐ Forking for commercial purposes | โ Yes | Creating derivative commercial products |
๐ญ Production use in any form | โ Yes | Live systems serving real users |
Specific Scenarios | ||
๐ Student projects and coursework | โ No | Academic use is encouraged |
๐๏ธ CI/CD pipelines (for commercial products) | โ Yes | Part of commercial development |
๐ง Email validation in production APIs | โ Yes | Production service usage |
๐ E-commerce checkout validation | โ Yes | Revenue-related validation |
๐ฑ Mobile apps (free with ads or paid) | โ Yes | Monetized applications |
Ask yourself these questions:
โจ Unlimited Usage - Use in all your production applications
๐ Priority Support - Direct support from our engineering team
๐ Regular Updates - Get the latest features and improvements
๐ก๏ธ Legal Protection - Full commercial rights and warranty
๐ข Enterprise Ready - Suitable for large-scale deployments
Ready to use email-validator-js in production?
๐๏ธ Purchase a License - Simple pricing, instant activation
๐ง Contact Sales - For enterprise or custom needs
FAQs
Advanced email validation with MX records, SMTP verification, disposable email detection, batch processing, and caching. Production-ready with TypeScript support.
The npm package @devmehq/email-validator-js receives a total of 1,365 weekly downloads. As such, @devmehq/email-validator-js popularity was classified as popular.
We found that @devmehq/email-validator-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.ย It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last weekโs supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.