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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tempmail-blocker

v1.0.1

Published

Block temporary/disposable email domains to prevent spam registrations

Readme

Tempmail Blocker

https://www.npmjs.com/package/tempmail-blocker

A lightweight npm package to block temporary/disposable email domains and prevent spam registrations.

Features

  • 4,493+ blocked domains - Comprehensive list of temporary email services
  • Zero dependencies - Lightweight and fast
  • Works everywhere - Browser, Node.js, React, Vue, Angular, etc.
  • TypeScript support - Full type definitions included
  • Easy to use - Simple API with multiple validation methods
  • Regularly updated - Domain list is actively maintained

Installation

npm install tempmail-blocker

Usage

Basic Usage

const { isTempMail } = require('tempmail-blocker');

// Check if an email uses a temporary domain
if (isTempMail('[email protected]')) {
  console.log('Temporary email detected!');
}

TypeScript

import { isTempMail, validateEmail } from 'tempmail-blocker';

// Check email
const isTemp = isTempMail('[email protected]');

// Validate and throw error if temporary
try {
  validateEmail('[email protected]');
} catch (error) {
  console.error(error.message); // "Temporary or disposable email addresses are not allowed"
}

Express.js Middleware Example

const { isTempMail } = require('tempmail-blocker');

app.post('/register', (req, res) => {
  const { email } = req.body;
  
  if (isTempMail(email)) {
    return res.status(400).json({
      error: 'Temporary email addresses are not allowed'
    });
  }
  
  // Continue with registration...
});

React Form Validation

import { isTempMail } from 'tempmail-blocker';

function RegistrationForm() {
  const [error, setError] = useState('');
  
  const handleSubmit = (email) => {
    if (isTempMail(email)) {
      setError('Please use a permanent email address');
      return;
    }
    setError('');
    // Continue with form submission...
  };
  
  return (
    <form>
      <input type="email" onChange={(e) => handleSubmit(e.target.value)} />
      {error && <p style={{color: 'red'}}>{error}</p>}
    </form>
  );
}

Browser / Vanilla JavaScript

<script type="module">
  import { isTempMail } from './node_modules/tempmail-blocker/dist/index.js';
  
  document.getElementById('emailForm').addEventListener('submit', (e) => {
    e.preventDefault();
    const email = document.getElementById('email').value;
    
    if (isTempMail(email)) {
      alert('Temporary email addresses are not allowed');
      return;
    }
    
    // Continue with form submission...
  });
</script>

Vue.js

import { isTempMail } from 'tempmail-blocker';

export default {
  data() {
    return {
      email: '',
      error: ''
    };
  },
  methods: {
    validateEmail() {
      if (isTempMail(this.email)) {
        this.error = 'Please use a permanent email address';
        return false;
      }
      this.error = '';
      return true;
    }
  }
};

API Reference

isTempMail(email: string): boolean

Check if an email address uses a temporary/disposable email domain.

Parameters:

  • email (string): The email address to check

Returns:

  • boolean: true if the email uses a blocked domain, false otherwise

Example:

isTempMail('[email protected]'); // true
isTempMail('[email protected]');    // false

isTempMailDomain(domain: string): boolean

Check if a domain is a temporary/disposable email domain.

Parameters:

  • domain (string): The domain to check

Returns:

  • boolean: true if the domain is blocked, false otherwise

Example:

isTempMailDomain('tempmail.com');  // true
isTempMailDomain('gmail.com');     // false

validateEmail(email: string): void

Validate an email address and throw an error if it uses a temporary domain.

Parameters:

  • email (string): The email address to validate

Throws:

  • Error: If the email uses a blocked domain

Example:

try {
  validateEmail('[email protected]');
} catch (error) {
  console.error(error.message);
}

isBlocked(domain: string): boolean

Alias for isTempMailDomain(). Check if a domain is blocked.

Parameters:

  • domain (string): The domain to check

Returns:

  • boolean: true if the domain is blocked, false otherwise

getBlockedDomainsCount(): number

Get the total number of blocked domains.

Returns:

  • number: The count of blocked domains

Example:

const count = getBlockedDomainsCount();
console.log(`Blocking ${count} domains`); // "Blocking 4493 domains"

getBlockedDomains(): string[]

Get all blocked domains as an array.

Returns:

  • string[]: Array of all blocked domains

Example:

const domains = getBlockedDomains();
console.log(domains); // ['tempmail.com', '10minutemail.com', ...]

Use Cases

  • User Registration: Prevent users from signing up with temporary emails
  • Newsletter Subscriptions: Ensure subscribers use permanent email addresses
  • Contact Forms: Block spam from temporary email services
  • E-commerce: Validate customer emails during checkout
  • API Rate Limiting: Prevent abuse through disposable emails

Blocked Domains

This package blocks over 4,493 temporary email domains including:

  • 10minutemail.com
  • guerrillamail.com
  • tempmail.com
  • mailinator.com
  • And many more...

Performance

  • Fast lookups: Uses a Set for O(1) domain checking
  • Lazy loading: Domains are loaded only when first needed
  • Memory efficient: Domains are cached in memory after first load
  • No external dependencies: Works completely offline
  • Browser compatible: No Node.js-specific APIs (fs, path, etc.)

Browser Support

This package works in all modern browsers and environments:

  • ✅ Chrome, Firefox, Safari, Edge
  • ✅ Node.js (v14+)
  • ✅ React, Vue, Angular, Svelte
  • ✅ Next.js, Nuxt.js, SvelteKit
  • ✅ Webpack, Vite, Rollup, esbuild
  • ✅ ES Modules and CommonJS

Contributing

Contributions are welcome! If you find a temporary email domain that should be blocked:

  1. Fork the repository
  2. Add the domain to domains.txt
  3. Submit a pull request

License

MIT

Support

For issues, questions, or suggestions, please open an issue on GitHub.