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

mailcheckr

v0.3.0

Published

Fast email validation with configurable syntax, DNS, disposable, and SMTP checks.

Downloads

491

Readme

mailcheckr

Fast email validation with configurable checks: syntax, typo detection, domain blocklists, disposable-domain filtering, MX DNS validation, and optional SMTP RCPT probing.

This library is designed for practical validation (signup/contact workflows), not full RFC-5321/5322 edge-case compliance.

  • Built with obuild
  • Works in Bun and Node.js runtimes
  • Designed to reduce network bottlenecks with cache, retries, and custom resolvers

What problem this solves

Most apps need more than regex. mailcheckr helps you:

  • reject malformed addresses early
  • prevent typo domains (hotnail.com -> hotmail.com)
  • block disposable/temporary providers
  • enforce your own blocked domains
  • validate that a domain can actually receive mail (MX records)
  • optionally probe mailbox acceptance via SMTP (no email body is sent)

Install

bun add mailcheckr

For local development in this repo:

bun install

Basic usage

import { checkEmail } from "mailcheckr";

const result = await checkEmail("[email protected]");

if (result.valid) {
  console.log("valid");
} else {
  console.log(result.reasonId, result.message);
}

Disable specific checks

Turn off disposable-domain check (your request):

const result = await checkEmail("[email protected]", {
  checkDisposable: false,
});

Other toggles:

await checkEmail("[email protected]", {
  checkTypo: false,
  checkBlocklist: false,
  checkVendorRules: false,
  checkMx: true, // keep DNS MX verification
});

All options

await checkEmail("[email protected]", {
  level: "dns", // "syntax" | "dns" | "deep"
  timeout: 3000,
  dnsServer: "",
  extraDisposableDomains: [],
  blocklistDomains: ["disposable-email.com"],
  checkBlocklist: true,
  checkDisposable: true,
  checkTypo: true,
  checkVendorRules: true,
  checkMx: true,
  cache: true,
  cacheTtl: 300_000,
  skipCache: false,
  usePopularMxCache: true,
  popularMxCache: {
    "company.com": ["mx.company.com"],
  },
  dohProviderUrl: "https://cloudflare-dns.com/dns-query",
  dohRetryAmount: 2,
  mxResolver: async (domain) => {
    return domain === "example.com" ? ["mail.example.com"] : [];
  },
  smtpProbe: false, // enable mailbox probe
  smtpProbeTimeoutMs: 2500, // timeout in milliseconds
  smtpProbeMaxMxHosts: 1, // keep low for speed
  smtpProbeCatchAllCheck: true,
});

usePopularMxCache helps reduce cold DNS latency for common providers by seeding known MX entries. dohProviderUrl and dnsServer are restricted to trusted allowlisted providers.

When smtpProbe is enabled, the checker performs SMTP handshake up to RCPT TO and stops before DATA (no message body sent). If SMTP probing is temporarily unavailable or timed out, the result remains valid when MX checks pass, and the smtp.status is unverifiable.

SMTP probe example (fast mode)

const result = await checkEmail("[email protected]", {
  smtpProbe: true,
  smtpProbeTimeoutMs: 1500,
  smtpProbeMaxMxHosts: 1,
});

console.log(result.valid, result.smtp?.status);

Custom error messages

import {
  checkEmail,
  INVALID_REASON_AMOUNT_OF_AT,
  INVALID_REASON_USERNAME_GENERAL_RULES,
  INVALID_REASON_DOMAIN_GENERAL_RULES,
  INVALID_REASON_NO_DNS_MX_RECORDS,
  INVALID_REASON_DOMAIN_IN_BLOCKLIST,
  INVALID_REASON_USERNAME_VENDOR_RULES,
  INVALID_REASON_DOMAIN_POPULAR_TYPO,
} from "mailcheckr";

const customReasons = {
  [INVALID_REASON_AMOUNT_OF_AT]: "Email must contain exactly one @ symbol",
  [INVALID_REASON_USERNAME_GENERAL_RULES]:
    "Username contains invalid characters",
  [INVALID_REASON_DOMAIN_GENERAL_RULES]: "Domain name is invalid",
  [INVALID_REASON_NO_DNS_MX_RECORDS]:
    "Domain does not have mail server records",
  [INVALID_REASON_DOMAIN_IN_BLOCKLIST]: "This email domain is not allowed",
  [INVALID_REASON_USERNAME_VENDOR_RULES]:
    "Username does not meet provider requirements",
  [INVALID_REASON_DOMAIN_POPULAR_TYPO]:
    "Domain appears to be a typo (did you mean gmail.com?)",
};

const result = await checkEmail("[email protected]");
if (!result.valid) {
  console.log(customReasons[result.reasonId!]);
}

Node.js custom MX resolver

import { resolveMx } from "dns/promises";
import { checkEmail } from "mailcheckr";

async function nodeResolver(emailDomain: string): Promise<string[] | false> {
  try {
    const records = await resolveMx(emailDomain);
    return records.map((rec) => rec.exchange);
  } catch (error) {
    const err = error as Error;
    if (err.message.includes("ENOTFOUND")) return [];
    return false;
  }
}

const result = await checkEmail("[email protected]", {
  mxResolver: nodeResolver,
});

Build and test

bun run build
bun test