smtp-email-verifier
v1.0.3
Published
An package to interrogate SMTP servers to see if an email exists
Downloads
6
Readme
Email Validator
How It Works
In laymen, it connects to the server where the email address exists and tries to ask it if it has a record of it. If so it will return something like this:
Successful
{
email: "[email protected],
mx_priority_1: "gmail-smtp-in.l.google.com",
mx_isValid: true
}
Error
{
email: "[email protected]"
error: <error object>
}
Not every server will cooperate but most will. Most notably I've run into issues with redhat.com
Contributing
If there is an issue or you think it needs a new feature, feel free to open an issue or PR.
Example
const { validate } = require('email-validator')
(async () => {
let isEmailValid = null
try {
// Verbose and timeout defaults; Mot needed to use the method.
isEmailValid = await validate({email: "[email protected]", verbose: true, timeout: 2000})
} catch(e) {
// handle invalid email / error
}
})()