The best way to check a misspelled email address in JavaScript
🔐 Reduce failed authentication ⬆️ Increase emails delivery ⚡️ Built for speed
@zootools/email-spell-checker
EmailSpellChecker is a lightweight JavaScript module written in TypeScript that suggests the right domain when your users misspell it in an email address.
At ZooTools - web3 Mailchimp alternative, we validate thousands of misspelled emails daily with EmailSpellChecker and it helped us to reduce bounced emails by 30%.
It's by far the easiest way to reduce misspelled email addresses in your web apps and server.
The features your deserve
We rewrote and improved mailcheck.js, a great module that is no longer maintained (7+ years since the last update) and we fixed critical bugs like this, or this.
⚡️ Lighting fast: Highly performance email checking using Sift3 - a fast and accurate string distance algorithm.
🔋 Updated: 39+ popular domains, and 66+ modern TLDs out-of-the-box. Frequently updated.
🚀 Ridiculously small: 1.8KB (minzip) and 0 external dependencies. We agree, big bundles suck!
💙 TypeScript: Fully written in TypeScript, cause we know you love it and we too.
⚙️ Extensible: Allows you to pass your custom rules and domains. Tweak it as you need.
🔨 1-minute migration: Same API and functions as mailcheck so you can switch in a sec!
🔐 Unit tested: Cause we'd not ever used a library without tests :).
Why should you validate email spelling?
Typos in the email will harm your business. Especially email deliverability. Common user misspellings such as “gnail” instead of “gmail” or “yaho” instead of “yahoo” can be used as spam traps by ISPs, and as a result, your emails will be blocked or marked as spam.
Common use cases:
User authentication (login, signup, email recovery).
Adding EmailSpellChecker to your project takes less than 5 minutes.
It works on any JavaScript framework (Vue, React, Next.JS, Angular, Svelte, etc) as well as your backend server.
Installation
Install with npm:
npm i @zootools/email-spell-checker --save
Install with yarn:
yarn add @zootools/email-spell-checker
Basic Example
Using the library is easy. Import it, call run function with the email you want to validate, and get a suggestion.
import emailSpellChecker from'@zootools/email-spell-checker';
const suggestedEmail = emailSpellChecker.run({
email: 'jorge@gmaik.co',
});
if (suggestedEmail) {
// DEV: Handle the suggestion.// E.g: tell the user their email is wrong and offer to apply your suggestion.console.log(suggestedEmail);
// {// address: "jorge"// domain: "gmail.com"// full: "jorge@gmail.com"// }
}
Extending Domains
EmailSpellChecker has inbuilt defaults if the domains, secondLevelDomains or topLevelDomains options aren't provided.
The out-of-the-box configuration is the best for 99% of cases. If you are that 1%, here is how you can extend the configuration :).
Adding your own Domains
You can replace EmailSpellChecker's default domain/TLD suggestions by supplying replacements to EmailSpellChecker.run:
mailSpellChecker.js (mail spell checker) is a lightweight module that suggests a right domain when your users misspell it in an email address
We found that @zootools/email-spell-checker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 1 open source maintainer collaborating on the project.
Package last updated on 18 Jan 2023
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
A malicious npm campaign is targeting Ethereum developers by impersonating Hardhat plugins and the Nomic Foundation, stealing sensitive data like private keys.