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

mailboxlayer-node-client

v1.0.13

Published

Client for MailBoxLayer API in TypeScript. Database can be connected to store email information.

Downloads

33

Readme

MailBoxLayer Node Client

Build Status

This library can be used to get email information. To get faster results, it is possible to enable the cache feature to store 1st-request email information in a database. This allows to reduce the number of API calls. It uses the MailBoxLayer API: https://mailboxlayer.com

Installation

yarn add mailboxlayer-node-client

or

npm install mailboxlayer-node-client --save

Configuration

Before using the mailboxlayer API client, set up your account and obtain your API Access Key. To get your Access Key, sign up at https://mailboxlayerlayer.com/product

SETUP

MailboxLayer constructor has an IConfig parameter:

interface  IConfig {
    // Given by mailbox after registration (Required) 
    accessKey:  string
    // If you want the API to perform SMTP checks (Required)
    smtp:  boolean
    //  The real-time verification process of the MailBoxLayer API does not end with one /// SMTP check (Required) 
    catchAll:  boolean
    // http or https (Required)
    secure:  boolean
    // If you want to use a database to save API responses (Optional)
    cache?:  boolean
    // Database connector (Required if cache === true)
    connector?:  AbstractConnector
}

Without cache

import {MailBoxLayer} from  '..'
import {accessKey} from  './config'

const  mailBoxLayer  =  new  MailBoxLayer(
	{
		accessKey, smtp :  true, 
		catchAll :  true, 
		secure :  false
	})

mailBoxLayer.getInformations('[email protected]')
	.then(email  => {
		// All your email information
		console.log(email)
	})
	.catch(err  => {
		console.error(err)
	})

With cache

With cache, you can use the following types of storage:

  • Memory (do not use in production)
  • Files (do not use in production)
  • MongoDB npm link
  • Redis (with bluebird) npm link

For example, with MongoDB: (you can find more examples in the /examples directory)

    new  Promise((resolve) => {resolve()})
	    .then(async () => {
		    const  mongoClient  =  await  MongoClient.connect(mongoConfig.serverUrl, { useNewUrlParser:  true })
		    const  db  =  mongoClient.db(mongoConfig.databaseName)
	        const  mongoCollection  =  db.collection('email')
		    const  mongoConnector  =  new  MongoConnector(mongoCollection)
		    
		    try {
			    const  mailBoxLayer  =  new  MailBoxLayer({
				    accessKey, smtp :  true,
				    catchAll :  true,
				    secure :  false,
				    cache :  true,
				    connector :  mongoConnector
			    })
			    const  email  =  await  mailBoxLayer.getInformations('[email protected]')
			    console.log(email)
	    } catch (error) {
		    console.error(error)
	    }
    })

Response

The following lines show the object returned after an API request (Email class):

{
    // Email to test
    email: string
    // Alternative email suggestion 
    didYouMean: string = ''
    // "paul" in "[email protected]'
    user: string = ''
    // "company.com" in "[email protected]"
    domain: string = ''
    // Depends on whether the general syntax of the requested email address is valid or not 
    formatValid: boolean = true
    // Depends on whether MX-Records for the requested domain could be found or not 
    mxFound: boolean = true
    // Depends on whether the SMTP check of the requested email address succeeded or not
    smtpChecked: boolean = true
    // Depends on whether the requested email address is found to be part of a catch-all mailbox or not
    catchAll: boolean = true
    // Depends on whether the requested email address is a role email address or not. (true if [email protected])
    role: boolean = true
    // Depends on whether the requested email address is a disposable email address or not
    disposable: boolean = false
    // Depends on whether the requested email address is a free email address or not
    free: boolean = true
    // Reflects the quality and deliverability of the requested email address
    score: number = 1
	// Result from cache or not
	alreadyInDatabase : boolean = false
}

Email class has the following methods:

canBeUseForTransactions()
canbeUsedForMarketing()

Stop Callbacks! Use Promises

This library does not use callback. Use promise instead.

Tests

In order to run the tests mongoDB and Redis must be installed.

yarn run test

or

npm run test

Connectors that can be used with this library

files

redis

mongodb