1.2.0 • Published 3 years ago

simple-email-verifier v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Simple Email Verification

This class can help you to check that some email is realy exists in the Internet. For example, if you don't want to send email verification message with code, but just want to check that email wasn't generated by RANDOM_EMAIL() function.

Method

  1. First, it's a simple regular expression checking. Verify that email have a normal format.
  2. Second, it's looking for MX records by DNS resolving.
  3. And the last step is checking for account exists in the SMTP server by sending some protocol messages.

Installation

npm i simple-email-verifier

Usage

const { EmailVerifier } = require("simple-email-verifier");

let verifier = new EmailVerifier(10000);

verifier.verify("admin@vk.com").then(result => {
  if (result) {
    console.log("This email realy exists :)");
  } else {
    console.log("Email not found :(");
  }
}).catch(console.error);

API

  • EmailVerifier(timeout: number, dnsCacheSettings: Object, mailFrom: string) - Main verifier class, where mailFrom - is your random server email, timeout - is timeout for email verify in .verifySmtpRecord() method. And dnsCacheSettings are settings for dnscache package.
  • verifier.verify(email: string): Promise<boolean> - Full email verify promise.
  • verifier.isValidEmail(email: string): boolean - Validate email by regular expression.
  • verifier.getEmailDomain(email: string): string - Get email domain after @ symbol.
  • verifier.checkMx(email: string): Promise<[]MxRecord> - Look for MX records by DNS resolve.
  • verifier.verifySmtpRecord(mxRecord: string, email: string): Promise<boolean> - Check email account existing in the SMTP server.

Typings

Some types of this module.

MxRecord

MX record object

  • exchange - Mail Exhange
  • priority - Exchange priority