vasya-email-validator
v0.0.2
Published
Validates emails based on regex, common typos, disposable email blacklists, DNS records and SMTP server response.
Downloads
4
Maintainers
Readme
Email Validator
Validates email addresses based on regex, common typos, disposable email blacklists, DNS records and SMTP server response.
- Validates email looks like an email i.e. contains an "@" and a "." to the right of it.
- Validates common typos e.g. [email protected] using mailcheck.
- Validates email was not generated by disposable email service using disposable-email-domains.
- Validates MX records are present on DNS.
- Validates SMTP server is running.
- Validates mailbox exists on SMTP server.
- Native typescript support.
Getting Started
Comaptible with nodejs only. Not browser ready.
Install like so
npm i vasya-email-validator --save
or with yarn
yarn add vasya-email-validator
Use like so
import validate from 'vasya-email-validator'
// or
// const {validate} = require("vasya-email-validator");
const main = async () => {
let res = await validate('[email protected]')
// {
// "valid": false,
// "reason": "smtp",
// "validators": {
// "regex": {
// "valid": true
// },
// "typo": {
// "valid": true
// },
// "disposable": {
// "valid": true
// },
// "mx": {
// "valid": true
// },
// "smtp": {
// "valid": false,
// "reason": "Mailbox not found.",
// }
// }
// }
// Can also be called with these default options
await validate({
email: '[email protected]',
sender: '[email protected]',
validateRegex: true,
validateMx: true,
validateTypo: true,
validateDisposable: true,
validateSMTP: true,
})
}