dns-email-validation
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

dns-email-validation

About

Test CI

dns-email-validation is a typescript library that performs deep validation for the existence of an email address with validation of DNS records.

The main idea is to receive DNS record data instantly, even if the domain or email was created recently. Improved validation interface.

Installation:

npm install dns-email-validation
#OR
yarn add dns-email-validation
#OR
pnpm add dns-email-validation

Interface

By default:

{
  MX: true;
}

You can specify additional settings:

export interface IDnsEmailValidationOptions {
  MX?: boolean; // validation of MX records
  NS?: boolean; // validation of NS records
  A?: boolean; // validation of A records
}

Error codes

  • MX - MX record is missing
  • NS - NS record is missing
  • A - A record is missing
  • BAD_EMAIL - email address was incorrectly
  • ENOTFOUND - domain does not exist
  • UNKNOWN - unknown error

Example:

console.log(await DnsEmailValidation.verify('mail@gmail.com')); // { verification: true }
console.log(await DnsEmailValidation.verify('mail@example.com')); // { verification: false, reason: [ 'MX' ] }

Example: dns-email-validation-example

License

Licensed under MIT (LICENSE / http://opensource.org/licenses/MIT)

Readme

Keywords

Package Sidebar

Install

npm i dns-email-validation

Weekly Downloads

17

Version

0.1.1

License

MIT

Unpacked Size

8.4 kB

Total Files

11

Last publish

Collaborators

  • 0xdino