Skip to content

An email utility to validate addresses, detect disposable domains, and normalize Gmail aliases for more secure user identification.

License

Notifications You must be signed in to change notification settings

ameghcoder/email-sentry

Repository files navigation

📧 email-sentry

Author NPM version License: MIT Run Tests


email-sentry is a lightweight and production-ready utility to:

  • ✅ Validate email format
  • 🚫 Detect disposable/temp email domains
  • 📩 Normalize Gmail aliases, e.g.
    • user+promo@gmail.comuser@gmail.com
    • E.X.A.M+test@gmail.comexample@gmail.com
    • User.Name+second@yahoo.comuser.name@yahoo.com (dots preserved in some clients)

Updates

  • 1.0.2 version
    • supports only the Gmail normalization
    • Contains 4.0k disposable domain name to validate
  • 1.1.0 version
    • supports @gmail.com, @yahoo.com, @outlook.com, @hotmail.com, @live.com, @msn.com, @icloud.com, @protonmail.com, @zoho.com (now a wide range to protect your website from spoofing and fake accounts)
    • Contains 4.5k disposable domain name to validate

Features

  • Simple API
  • Tiny & dependency-light
  • Helps prevent spam/bots during user signups
  • Supports thousands of disposable email providers
  • Built in TypeScript (fully typed)

Installation

npm install email-sentry
# or
yarn add email-sentry

Usage

import { emailSentry } from "email-sentry";

const result = emailSentry("user+promo@mailinator.com", {
  validate: true,
  checkDisposable: true,
  normalizeGmailAliases: true, //deprecated
  normalizeEmail: true // Use this instead of normalizeGmailAliases
});
/*
normalizeGmailAliases and normalizeEmail gives the same result
*/

console.log(result);
/*
{
  inputEmail: 'user+promo@mailinator.com',
  success: true,
  isValid: true,
  isDisposable: true,
  outputEmail: 'user@gmail.com'
}
*/

Options

Option Type Description
validate boolean Validates email using the powerful email validator package
checkDisposable boolean Checks against known disposable email domains, contains 5000+ disposable domains data
@deprecated normalizeGmailAliases boolean Removes +something from Gmail addresses and prevent the same email address to use to create account, use normalizeEmail instead
normalizeEmail boolean Removes +something from All email clients like yahoo, zoho, msn, outlook and more client email addresses and prevent the same email address to use to create account

Testing

Run all tests with:

npm test

Or watch mode:

npm run test:watch

License

MIT © Yashraj


Author

Made with ❤️ by Yashraj

If you like this project, consider ⭐️ starring the repo or sharing it. It helps a lot!

About

An email utility to validate addresses, detect disposable domains, and normalize Gmail aliases for more secure user identification.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published