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

disposable-email-validator

v1.1.0

Published

Block disposable emails with environment-specific rules and plus addressing validation

Readme

Disposable Email Validator

npm types license tests

Filter temporary/disposable email domains and normalize email addresses, with environment-specific rules.


Features

  • Block disposable email addresses
  • Optional plus addressing validation (e.g., [email protected])
  • Allowlist support for trusted emails/domains
  • Environment-based configuration (use any environment names: development, staging, production, my-app-env, etc.)
  • Fully typed with TypeScript

Installation

npm install disposable-email-validator

Quick Start

import { DisposableEmailValidator } from 'disposable-email-validator';

const config = {
  production: {
    rules: {
      allow_disposable_emails: false,
      allow_plus_addressing: false,
    }
  }
};

const validator = new DisposableEmailValidator('production', config);

const result = validator.validateEmail('[email protected]');
console.log(result);
// { success: false, error: 'Disposable email addresses are not allowed' }

Configuration

The library uses environment-based configuration to support different validation rules across any environment you define. While development, staging, production, and test are common examples, you can use any environment names that match your setup.

Full Example

const config = {
  development: {
    rules: {
      allow_disposable_emails: true,
      allow_plus_addressing: true
    }
  },
  production: {
    rules: {
      allow_disposable_emails: false,
      allow_plus_addressing: false
    },
    disposableDomains: ['10minutemail.com', 'tempmail.org'],
    trustedDomains: ['company.org', 'company.com'],
    mergeDisposableDomains: true
  },
  'my-custom-env': {
    rules: {
      allow_disposable_emails: true,
      allow_plus_addressing: false
    },
    disposableDomains: ['custom-temp.com'],
    mergeDisposableDomains: false
  }
};

Configuration Reference

| Key | Type | Required | Default | Description | |--------------------|-------------|----------|-------------------|-------------| | rules.allow_disposable_emails | boolean | Yes | – | Blocks disposable domains | | rules.allow_plus_addressing | boolean | Yes | – | Blocks plus-addressed emails | | disposableDomains | string[] | No | Built-in list | Custom domains to block | | trustedDomains | string[] | No | undefined | Emails/domains to allow regardless of rules | | mergeDisposableDomains | boolean | No | true | Whether to merge custom domains with built-in list |

Custom Disposable Domains

The mergeDisposableDomains option controls how your custom disposableDomains list is handled:

  • true (default): Your custom domains are added to the built-in list
  • false: Only your custom domains are used (built-in list is ignored)
// Example: Merge with built-in list (recommended)
{
  production: {
    rules: { allow_disposable_emails: false, allow_plus_addressing: false },
    disposableDomains: ['company-temp.com'],
    mergeDisposableDomains: true  // Blocks both built-in domains AND company-temp.com
  }
}

// Example: Use only custom domains
{
  production: {
    rules: { allow_disposable_emails: false, allow_plus_addressing: false },
    disposableDomains: ['company-temp.com'],
    mergeDisposableDomains: false  // Only blocks company-temp.com (allows 10minutemail.com, etc.)
  }
}

API

Constructor

new DisposableEmailValidator(environment: string, config: DisposableEmailValidatorConfig)
  • environment: the name of any environment defined in your config (e.g., production, development, staging, my-custom-env, etc.)
  • config: your full multi-environment configuration object

validateEmail(email: string): ValidationResult

Returns:

{ success: true, error: null }
// or
{ success: false, error: string }

Error Messages

  • 'Invalid email format'
  • 'Disposable email addresses are not allowed'
  • 'Plus addressing is not allowed'

Default Blocked Domains

If disposableDomains is not provided, this package includes a prebuilt list from disposable-email-domains.

You get coverage for thousands of known throwaway providers out of the box.


Why Use This?

  • Designed for production apps
  • Prevent fake signups from temporary emails
  • Multiple environments supported
  • Built-in domain blacklist
  • Fast + typesafe + extendable

License

MIT — LICENSE


Contributing

Pull requests are welcome! If you'd like to add a feature, fix a bug, or improve documentation:

  1. Fork the repo
  2. Create your branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -am 'Add feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Open a PR

Contact

Made with ❤️ by Wilson Adenuga - @Adenugawilson - [email protected]


Support

If you find this package useful, please consider ⭐ starring the repository on GitHub! It helps others discover the project and motivates continued development.