npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@gradeup/email-verify

v0.2.4

Published

A tool to verify an email address exits via SMTP

Downloads

3,398

Readme

SMTP Email Verification

Note

Forked from https://github.com/EmailVerify/email-verify.git. This package is not actively maintained.

Install

npm install -g email-verify

Important Note

If you upgrade to > 0.0.12 from a previous version, you will need to make minor changes in your code. The callback was made to be error first.

Usage

You can use it stand alone with the email-verify command and as many email addresses as you want to check.

email-verify [email protected] [email protected]

Using -d

email-verify -d domain.com addr1 addr2 addr3

Using -d -s, checking the standard email addresses

email-verify -d domain.com -s

Using -d -n, checking for variations of a name [-n firstname lastname]

email-verify -d domain.com -n firstname lastname

Using it in a more complicated way

email-verify -d domainA.com addr1 addr2 -n firstname1 lastname1 -d domainB -n firstname2 lastname2

Each time you use -d, it treats everything after it as that domain until another domain is used. Until you use -d, it treats it as there is no domain so you can't do -s or -n.

Other options supported are -p port, -t timeout, -sd [email protected], -f FDQN, -dns DNSIPADDRESS, -c concurrency, --file / -file FILEPATH

The FDQN is used on the first HELO of the SMTP protocol. Defaults for the sender are [email protected] and default for the FDQN is mail.example.org. Strongly suggested that you change these. (Previous ones used my email / domain, just removed that)

The module has one asynchronous method: verify( email, options, callback )

Callback

The callback is a function(err, info) that has an info object:

{
  success: boolean
  info: string
  addr: the address being verified
  code: info code saying things on verification status
  banner: how server advertize itself
}

Options

The options are:

{
  port : integer, port to connect with defaults to 25
  sender : email, sender address, defaults to [email protected]
  timeout : integer, socket timeout defaults to 0 which is no timeout
  fqdn : domain, used as part of the HELO, defaults to mail.example.org
  dns: ip address, or array of ip addresses (as strings), used to set the servers of the dns check,
  ignore: set an ending response code integer to ignore, such as 450 for greylisted emails
}

Flow

The basic flow is as follows:

  1. Validate it is a proper email address
  2. Get the domain of the email
  3. Grab the DNS MX records for that domain
  4. Create a TCP connection to the smtp server
  5. Send a EHLO message
  6. Send a MAIL FROM message
  7. Send a RCPT TO message
  8. If they all validate, return an object with success: true. If any stage fails, the callback object will have success: false.

This module has tests with Mocha. Run npm test and make sure you have a solid connection.

Use (also see the app.js file):

var verifier = require('email-verify');
var infoCodes = verifier.infoCodes;

verifier.verify( '[email protected]', function( err, info ){
  if( err ) console.log(err);
  else{
    console.log( "Success (T/F): " + info.success );
    console.log( "Info: " + info.info );

    //Info object returns a code which representing a state of validation:

    //Connected to SMTP server and finished email verification
    console.log(info.code === infoCodes.finishedVerification);

    //Domain not found
    console.log(info.code === infoCodes.domainNotFound);

    //Email is not valid
    console.log(info.code === infoCodes.invalidEmailStructure);

    //No MX record in domain name
    console.log(info.code === infoCodes.noMxRecords);

    //SMTP connection timeout
    console.log(info.code === infoCodes.SMTPConnectionTimeout);

    //SMTP connection error
    console.log(info.code === infoCodes.SMTPConnectionError)
  }
});

Changes

0.0.10 -> 0.0.11 : changed "CR" to "CRLF" as per SMTP Standard. Added a QUIT message so that the connection is closed from both ends. (thanks @Nomon)

0.0.11 -> 0.0.12 : some refactoring and styles from james075. important to note, the callback order was changed to be error first. if you upgrade to here, you will need to modify your existing code.

0.0.12 -> 0.0.13 : fix cli -t timeout option

0.0.13 -> 0.0.14 : fix on error callback order added the capability to specify the DNS servers for the MX record checking programatically and via cli

0.0.14 -> 0.0.15 : prevent socket from writing after end event fires

0.0.15 -> 0.0.16 : added an ignore option for ignoring greylisted responses

0.0.16 -> 0.0.17 : sancowinx added a file option for the command line

0.0.17 -> 0.0.18 : zh99998 added concurrency to the command line options by adding bluebird

0.0.18 -> 0.1.0 : refactored the verify function to make it compatible with promisfy (bluebird) included changes from Bramzor to allow for greylisting rechecking and to allow for weird addresses more aligned to the RFCs removed the lodash dependency

0.1.0 -> 0.1.1 : fones fixed a typo for the fqdn parameter and added some logging

0.1.1 -> 0.2.0 : provide banner object in callback, use more actual dependencies, properly call mocha for unit tests

0.2.0 -> 0.2.1 : derain adding a return code, robert-irribarren adding try-again / fixes, bryant1410 fixing markdown thanks all! sorry for the late merges!