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

@sefinek/email-validator

v2.1.0

Published

Lightweight npm module for email address validation with optional MX record verification.

Readme

📨 Email Address Validator

This lightweight module provides precise email address validation, plus optional MX record verification of the domain, returning a Boolean value (true or false).

🟢 » Node.js

Installation via npm

npm install @sefinek/email-validator

Installation via yarn

yarn add @sefinek/email-validator

Example

const emailValidator = require('@sefinek/email-validator');

const TEST_EMAIL = '[email protected]';
if (emailValidator(TEST_EMAIL)) {
    console.log(`Email ${TEST_EMAIL} is valid.`);
} else {
    console.log(`Email ${TEST_EMAIL} is NOT valid!`);
}

MX record verification (Node.js only)

Beyond syntax validation, you can check whether the domain actually accepts mail by verifying its MX records. The function lives under the /mx subpath because it depends on node:dns and is therefore not included in the browser bundle. It accepts a full email address (the domain after the last @ is used) or a bare domain. It never throws and resolves exclusively to a Boolean.

const emailValidator = require('@sefinek/email-validator');
const verifyMx = require('@sefinek/email-validator/mx');

const TEST_EMAIL = '[email protected]';

// Cheap, synchronous syntax check first; only hit DNS if it passes.
if (emailValidator(TEST_EMAIL) && await verifyMx(TEST_EMAIL)) {
    console.log(`Email ${TEST_EMAIL} is valid and the domain accepts mail.`);
}

By default, the system resolvers are used. You can query specific DNS servers (and tune timeout/tries) via the optional second argument. This uses a dedicated resolver and never mutates the global DNS configuration:

await verifyMx('[email protected]', {
    servers: ['1.1.1.1', '8.8.8.8'], // each entry may include a port, e.g. '8.8.8.8:53'
    timeout: 2000,                   // ms per query before a retry (-1 = system default)
    tries: 2,                        // attempts before giving up
    validateSyntax: true,            // reject syntactically invalid addresses before any DNS lookup
});

With validateSyntax: true, the input is first checked against the syntax validator and an invalid address resolves to false without a DNS query. Note that this requires a full email address, so a bare domain is rejected when the flag is enabled.

🌍 » Browser

jsdelivr.net

https://cdn.jsdelivr.net/npm/@sefinek/email-validator@2/dist/email-validator.min.js

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>email-validator</title>
</head>
<body>
    <h1>email-validator</h1>

    <script src="https://cdn.jsdelivr.net/npm/@sefinek/email-validator@2/dist/email-validator.min.js"></script>
    <script>
        const email = '[email protected]';

        if (emailValidator(email)) {
            console.log(`✔️ Email ${email} is valid.`);
        } else {
            console.log(`❎ Email ${email} is NOT valid!`);
        }
    </script>
</body>
</html>

Demo

https://sefinek.net/projects/email-validator

⭐ » Thank you

If you find this module helpful, please consider giving the repository a star. For any questions or issues, please create a new Issue.

🔑 License

Copyright © Sefinek. Licensed under the MIT License.