
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
mail-validatr
Advanced tools
mail-validatr is a lightweight Node.js library and CLI tool for validating email addresses.
It checks syntax, domain validity, and MX records to ensure an email address is not just well-formed, but also likely to exist.
Install the library via npm:
npm install mail-validatr
For global CLI usage:
npm install -g mail-validatr
Import and use the validateEmail
function:
import { validateEmail } from "mail-validatr";
async function checkEmail() {
const result = await validateEmail("user@example.com");
console.log(result);
}
checkEmail();
Example output:
{
"isValidSyntax": true,
"hasValidDomain": true,
"hasMxRecords": true,
"warnings": [],
"recommended": true
}
For environments without network access, you can skip DNS and MX record validation:
await validateEmail("user@example.com", { skipDnsCheck: true });
You can define custom rules for additional validation:
const customRules = [
(email: string) =>
email.endsWith("@example.com")
? { code: "example_com_not_allowed", message: "Emails from example.com are not allowed." }
: null,
];
await validateEmail("user@example.com", { customWarningRules: customRules });
Example output with warnings:
{
"isValidSyntax": true,
"hasValidDomain": true,
"hasMxRecords": true,
"warnings": [
{
"code": "example_com_not_allowed",
"message": "Emails from example.com are not allowed."
}
],
"recommended": false
}
Validate email addresses directly from the command line:
mail-validatr user@example.com
Output:
[RESULT] Validation result for user@example.com:
- Syntax valid: true
- Domain valid: true
- MX records found: true
- Warnings: None
- Recommended: Yes
Use the --skip-dns
flag to skip DNS and MX record validation:
mail-validatr user@example.com --skip-dns
Enable verbose output with the --verbose
flag:
mail-validatr user@example.com --verbose
validateEmail(email: string, options?: ValidationOptions): Promise<EmailValidationResult>
true
, skips DNS and MX record validation.An EmailValidationResult
object:
interface EmailValidationResult {
isValidSyntax: boolean;
hasValidDomain?: boolean;
hasMxRecords?: boolean;
warnings: Array<{ code: string; message: string }>;
recommended: boolean;
}
You can see real-world usage of mail-validatr
in action:
This repository contains:
npm run build
npm run dev:test
npx vitest
MIT © 2025
Made with ❤️ by Jindrich Bobek
FAQs
Email validation CLI and library with DNS, MX, and warning checks.
The npm package mail-validatr receives a total of 21 weekly downloads. As such, mail-validatr popularity was classified as not popular.
We found that mail-validatr 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.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.