npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mail-validatr

v1.0.6

Published

Email validation CLI and library with DNS, MX, and warning checks.

Readme

mail-validatr

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.

npm license CI


Features

  • 📬 Syntax Validation — Checks if an email matches standard formats.
  • 🌐 Domain Verification — Verifies if the domain is real and reachable.
  • 📨 MX Record Lookup — Confirms that the domain accepts emails (via MX records).
  • Fast and Lightweight — Minimal dependencies, fast execution.
  • 🛠️ CLI and Programmatic API — Use in scripts or integrate into your Node.js apps.
  • 🛡️ Custom Rules — Add custom validation rules or disposable email lists.
  • Recommended Check — Indicates if the email is valid and free of warnings.

Installation

Install the library via npm:

npm install mail-validatr

For global CLI usage:

npm install -g mail-validatr

Usage

Programmatic (Node.js)

Import and use the validateEmail function:

import { validateEmail } from "mail-validatr";

async function checkEmail() {
  const result = await validateEmail("[email protected]");
  console.log(result);
}

checkEmail();

Example output:

{
  "isValidSyntax": true,
  "hasValidDomain": true,
  "hasMxRecords": true,
  "warnings": [],
  "recommended": true
}

Skipping DNS Checks

For environments without network access, you can skip DNS and MX record validation:

await validateEmail("[email protected]", { skipDnsCheck: true });

Adding Custom Warning Rules

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("[email protected]", { 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
}

CLI

Validate email addresses directly from the command line:

mail-validatr [email protected]

Output:

[RESULT] Validation result for [email protected]:
- Syntax valid: true
- Domain valid: true
- MX records found: true
- Warnings: None
- Recommended: Yes

Skipping DNS Checks

Use the --skip-dns flag to skip DNS and MX record validation:

mail-validatr [email protected] --skip-dns

Verbose Output

Enable verbose output with the --verbose flag:

mail-validatr [email protected] --verbose

API

validateEmail(email: string, options?: ValidationOptions): Promise<EmailValidationResult>

Parameters:

  • email (string): The email address to validate.
  • options (object, optional):
    • skipDnsCheck (boolean): If true, skips DNS and MX record validation.
    • customDisposableList (string[]): Add custom disposable email domains.
    • customWarningRules (Array<(email: string) => { code: string; message: string } | null>): Add custom warning rules.

Returns:

An EmailValidationResult object:

interface EmailValidationResult {
  isValidSyntax: boolean;
  hasValidDomain?: boolean;
  hasMxRecords?: boolean;
  warnings: Array<{ code: string; message: string }>;
  recommended: boolean;
}

🧪 Example Projects

You can see real-world usage of mail-validatr in action:

This repository contains:

  • Client Demo — Frontend-only validation with syntax + warning checks (Next.js + React + Tailwind).
  • Server Demo — Full email validation with DNS & MX lookup using server routes.

Useful Scripts

  • Build: npm run build
  • Dev Mode (watch + test): npm run dev:test
  • Run Tests: npx vitest

License

MIT © 2025
Made with ❤️ by Jindrich Bobek