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

art-email-validator

v1.2.7

Published

Art.Email.Validator

Downloads

11

Readme

Art.Email.Validator

Validate email and suggest corrections. Steps:

  1. check the domain syntactically - just a rough, quick-check
  2. look up the MX record for the domain, fail if it doesn't exist
  3. communicate with the SMTP server on the MX-server to determine if the mailbox exists
  4. if the SMTP server responds ambiguously, optionally, invoke fallbackValidator - useful to call an external, premium validation service

Always returns a results-object regardless of what happens, example output:

  • valid: true/false
  • invalid: true/false
  • didYouMean: '...@...' (provided by mailcheck)
  • message: 'details about what happened'

The most important results, valid and invalid will only be set to true if there is a strong confirmation that they are true. Therefor, they can can be true/false, false/true or false/false respectively, but never true/true. In the false/false case, the result is ambiguous. The email passed several tests, but didn't get a hard confirmation from the email server that the address exists.

Note: additional fields may be returned with additional information about the validation for introspection and logging purposes.

Install

npm install art-email-validator

Usage

&ArtEmailValidator.validateEmail
  email:    "foobar@gmailcom"         # email to check
  smtpHost: "my.domain.com"           # your domain, the same every call
.then (results) ->

# Example output:
results =
  valid:      false                   # possibly invalid
  invalid:    true                    # definitely invalid
  didYouMean: "[email protected]"      # suggested fix
  message:    "Domain was not valid." # developer-friendly info

API

&ArtEmailValidator.validateEmail options
.then (results) ->

# NOTE: &ArtEmailValidator means: require('art-email-validator')

options<object>

  • email<string> (required) the email address to check
  • smtpFrom<string> (required OR smtpHost) the smtpFrom-address to tell the email server [default: email]
  • smtpHost<string> (required OR smtpFrom) the smtpHost to tell the email server [default: the domain of part of: smtpFrom]
  • timeout<number-milliseconds> (default: 1000) number in miliseconds to wait before timing out when checking mailbox
  • fallbackValidator<(options, results) -> results> Called as the very last step if validateMailbox can't conclusively determine if it is valid. Example: use this to call Mailgun's email validation service.
  • verbose<bool/number> (default: false) verbose: true ==> basic verbos logging, verbose: >= 2 ==> very verbose logging

results<object>

  • valid<bool> 'true' means the email is definitly valid
  • invalid<bool> 'true' means email is definitly invalid
  • didYouMean<string> (optional) suggest a possibly-correct email
  • message<string> developer-consumable description of what happened

Note, the result is ambiguous if valid == false, but invalid != true. This indicates the SMTP server failed to respond in a known way and there was no fallbackValidator.

Trivia

  • Gmail.com ignores dots in email names, and it's a problem. This validator will generally succeed because Gmail.com will report that the mailbox exists. However, if you are using Mailgun, mailgun will refuse to actually send the email if it has extra dots: https://jameshfisher.com/2018/04/07/the-dots-do-matter-how-to-scam-a-gmail-user