1.0.6 • Published 2 years ago

email-domain-verifier v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

email-domain-verifier

A npm package that verifies email domains via dns mx records and attempting smtp connection

Installation

npm install email-domain-verifier --save

Usage

import { verifyEmailDomain } from 'email-domain-verifier'


await verifyEmailDomain('mailbox@gmail.com', { requireSmtpOrMx: true })
//  {
//    verified: true,
//    mxVerificationSucceed: true,
//    smtpVerificationSucceed: undefined
//  }

await verifyEmailDomain('mailbox@garbage.domain', { requireSmtpOrMx: true })
//  {
//    verified: false,
//    mxVerificationSucceed: false,
//    smtpVerificationSucceed: false
//  }

Options

{
  mxNotRequired?: boolean,         // Verify via smtp connection check only 
                                   // Mx records would still be resolved for smtp check
                                   // default: false

  smtpNotRequired?: boolean,       // Verify via dns mx records check only
                                   // default: false

  requireSmtpOrMx?: boolean,       // Require at least one check to succeed
                                   // default: false

  smtpConnectionTimeout?: number,  // Timeout for smtp connection in milliseconds
                                   // default: 1000

  useCache?: boolean               // Use in-memory lru cache
                                   // default: true
}

Details

Cache

  • Simple in-memory lru cache
  • Verification with { useCache: false } doesn't fetch cache, but still updates it
  • Only successful verifications get stored in cache
  • Max cache size is 1000 and ttl is 24 hours

Smtp check

  • Conducted via attempting tcp connection to popular smtp ports
  • Ports list is [ 25, 456, 587, 2525 ]
  • The check is successful if at least one of these ports is open on any of the mail exchange servers
  • In addition to mail exchange servers, these ports are scanned on `${domain}` and `smtp.${domain}`
  • Most public ISP block requests to port 25, so port 25 scan might not work from your home, but should work from your server

Mx check

  • The check is successful if domain has at least one mx record

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago