Published on

Blocking Temporary Email Addresses with Node.js


Disposable or temporary email addresses are great for protecting our privacy but cause an issue for a business that depends on our email address. For example, you provide a free trial or have a newsletter where you don't want a fake audience who messes up your metrics and resources

We can almost instantly create a temporary email address like tools like Mailinator

Code Snippet

Here's how to block temporary email addresses without relying on any third-party services

const tempEmailDomains = [
  // add more temp email domains here

const isTemporaryEmail = (email) => {
  const domain = email.split('@')[1];
  return tempEmailDomains.includes(domain);

// example usage
const email = '';
if (isTemporaryEmail(email)) {
  console.log('This is a temporary email address');
} else {
  console.log('This is a valid email address');

This basic approach should be able to block a large number of temporary email addresses and cover most of the use cases.

Further, we can implement DNS-based techniques to figure out and block custom domain-based temporary emails as well.

Disposable email address domains dataset

As for the temporary or disposable email address dataset, we can source it from disposable-email-domains or other similar repositories like burner-email-providers

Prefer using third-party services instead?

Verifier seems like a good free service that you can use it.

Happy blocking emails!