smtp-email-verifier

1.0.3 • Public • Published

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: "kyle@gmail.com,           
    mx_priority_1: "gmail-smtp-in.l.google.com",
    mx_isValid: true
}

Error
{
    email: "kyle@gmail.com"
    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: "kyle@gmail.com", verbose: true, timeout: 2000})
        
    } catch(e) {

        // handle invalid email / error
        
    }

})()

Package Sidebar

Install

npm i smtp-email-verifier

Weekly Downloads

6

Version

1.0.3

License

ISC

Unpacked Size

5.31 kB

Total Files

5

Last publish

Collaborators

  • quesurfin