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

smtp-ping

v1.0.0

Published

Verify an email address through SMTP ping

Downloads

18

Readme

smtp-ping

Verify an email address through SMTP Ping

"SMTP Ping" is an attempt to connect and exchange information with a mail exchanger server using the SMTP protocol in order to validate the existence of a email box address.

The smtp ping flow consists of a DNS record query(MX) to find the mail exchanger server followed by an attempt to "send"(the email is never sent) an email to a recipient. The process is interrupted at the moment that the server confirms the existence of the recipient.

Note that pinging an email address does not produce a reliable result. Many mail exchanger servers implement strict policies when exchanging information with unknown hosts, so false positive results are expected.

Installation

npm install --save smtp-ping

Usage

const { ping, SmtpPingStatus } = require('smtp-ping');

ping('[email protected]')
  .then(result => console.log(result))
  .catch(error => console.error(error));

Overriding the default settings:

const { ping, SmtpPingStatus } = require('smtp-ping');

const config = { sender: '[email protected]', port: 26, timeout: 5000 };
ping('[email protected]', config)
  .then(result => console.log(result))
  .catch(error => console.error(error));

The code above will produce the following result:

{
  complete:       boolean,
  status:         string,
  sender:         string,
  recipient:      string,
  fqdn:           string,
  host:           string,
  port:           number,
  timeout:        number,
  error:          <Error Object> | undefined,
  commandHistory: [
    { 
      command: string, 
      response: string, 
      code: number
    }
  ]
}

| Attribute | Value | Default | Description | | -------------- | ---------------------------- | ------------------ | ----------------------------------------------------------- | | complete | true or false | None | Indicates if the ping is complete | | status | 'OK', 'INVALID' or 'UNKNOWN' | None | Email box address status | | sender | 'any@email' | Randomly Generated | Email address of the sender | | recipient | 'any@email' | None | Email address of the recipient | | fqdn | 'domain.com' | None | Domain of the recipient's email | | host | 'domain.com' | None | Mail exchanger server host | | port | 25 | 25 | Mail exchanger server port | | timeout | 3000 | 3000 | Socket idle timeout in milliseconds | | error | Error object | None | Error object containing the details of the exception | | commandHistory | [{command, response, code}] | None | Array of objects containing the SMTP commands and responses |

The complete attribute will only be true in two scenarios:

  1. Mail exchanger host not found(no MX record found) or client not able to connect to mail exchanger server.

  2. SMTP ping flow is complete(sending and receiving SMTP commands).

The status attribute will be:

OK - Only if the smtp server explicitly confirms the availability of the mailbox address;

INVALID - If the smtp server explicitly confirms the mailbox is unavailable or if the client is unable to connect to the mail exchanger server;

UNKNOWN - For every other scenario(Idle Timeout, Transmission error, Connection closed before completing the smtp pipeline, etc).

License

This code is licensed under the MIT License.

All files located in the node_modules and external directories are externally maintained libraries used by this software which have their own licenses; we recommend you read them, as their terms may differ from the terms in the MIT License.