Giter VIP home page Giter VIP logo

email-check's Introduction

Email check

David npm

Introduction

Email check is a npm async module for NodeJS, that checks if an email address exists.

It first validates the email through regex, and then pings the relative MX server.

It works with native JS promises (and needs a JS engine that supports them, like Node >= v4.0.0).

Install

npm install email-check

(add "--save" if you want the module to be automatically added to your project's "package.json" dependencies)

Usage

emailCheck(email, [opts])

The function signature accepts two arguments and returns a promise, eventually fulfilled with true if the email address exists, or false if it doesn't (please note that if your Internet connection is down, or port 25 is closed โ€“ e.g. by a firewall โ€“ it will always return false).

  • email (string) the email address to check.
  • opts (object) the options object.

The options object can have three properties:

  • from (string) email address originating the request (defaults to the same value as "email").
  • host (string) fqdn of SMTP server originating the request (defaults to the domain name of the "from" email address).
  • timeout (number) max allowed idle time in milliseconds (defaults to 5000). If the timeout expires, the promise returns false.

Example

var emailCheck = require('email-check');

// Quick version
emailCheck('[email protected]')
  .then(function (res) {
    // Returns "true" if the email address exists, "false" if it doesn't.
  })
  .catch(function (err) {
    if (err.message === 'refuse') {
      // The MX server is refusing requests from your IP address.
    } else {
      // Decide what to do with other errors.
    }
  });

// With custom options
emailCheck('[email protected]', {
  from: '[email protected]',
  host: 'mail.domain.com',
  timeout: 3000
})
  .then(function (res) {
    console.log(res);
  })
  .catch(function (err) {
    console.error(err);
  });

MIT License

email-check's People

Contributors

pensierinmusica avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.