1 | # Advanced Email Validator
|
2 |
|
3 | [![NPM version](https://badgen.net/npm/v/@devmehq/email-validator-js)](https://npm.im/@devmehq/email-validator-js)
|
4 | [![Build Status](https://github.com/devmehq/email-validator-js/workflows/CI/badge.svg)](https://github.com/devmehq/email-validator-js/actions)
|
5 | [![Downloads](https://img.shields.io/npm/dm/email-validator-js.svg)](https://www.npmjs.com/package/email-validator-js)
|
6 | [![UNPKG](https://img.shields.io/badge/UNPKG-OK-179BD7.svg)](https://unpkg.com/browse/@devmehq/email-validator-js@latest/)
|
7 |
|
8 | Verify email address checking MX records, and SMTP connection, check for disposable email addresses and free email providers.
|
9 |
|
10 | ## Features
|
11 | ✅ Check email address validity
|
12 |
|
13 | ✅ Check email address domain validity in domain TLD list
|
14 |
|
15 | ✅ Check email address MX records
|
16 |
|
17 | ✅ Check email address SMTP connection
|
18 |
|
19 | ✅ Check email address disposable or burnable status
|
20 |
|
21 | ✅ Check email address free email provider status
|
22 |
|
23 | 🚨 Check domain age and quality score - _**soon**_
|
24 |
|
25 | 🚨 Check domain registration status - _**soon**_
|
26 |
|
27 | ## Use cases
|
28 | - Increase delivery rate of email campaigns by removing spam emails
|
29 | - Increase email open rate and your marketing IPs reputation
|
30 | - Protect your website from spam, bots and fake emails
|
31 | - Protect your product signup form from fake emails
|
32 | - Protect your website forms from fake emails
|
33 | - Protect your self from fraud orders and accounts using fake emails
|
34 | - Integrate email address verification into your website forms
|
35 | - Integrate email address verification into your backoffice administration and order processing
|
36 |
|
37 |
|
38 | ## API / Cloud Hosted Service
|
39 | We offer this `email verification and validation and more advanced features` in our Scalable Cloud API Service Offering - You could try it here [Email Verification](https://dev.me/products/email)
|
40 |
|
41 |
|
42 | ## Self-hosting - installation and usage instructions
|
43 |
|
44 | ## Installation
|
45 | Install the module through YARN:
|
46 | ```yarn
|
47 | yarn add @devmehq/email-validator-js
|
48 | ```
|
49 | Or NPM
|
50 | ```npm
|
51 | npm install @devmehq/email-validator-js
|
52 | ```
|
53 |
|
54 | ## Examples
|
55 | ```typescript
|
56 | import { verifyEmail } from '@devmehq/email-validator-js';
|
57 |
|
58 | const { validFormat, validSmtp, validMx } = await verifyEmail({ emailAddress: 'foo@email.com', verifyMx: true, verifySmtp: true, timeout: 3000 });
|
59 | // validFormat: true
|
60 | // validMx: true
|
61 | // validSmtp: true
|
62 | ```
|
63 |
|
64 | When a domain does not exist or has no MX records, the domain validation will fail, and the mailbox validation will return `null` because it could not be performed:
|
65 |
|
66 | ```typescript
|
67 | const { validFormat, validSmtp, validMx } = await verifyEmail({ emailAddress: 'foo@bad-domain.com', verifyMx: true, verifySmtp: true, timeout: 3000 });
|
68 | // validFormat: true
|
69 | // validMx: false
|
70 | // validSmtp: null
|
71 | ```
|
72 |
|
73 | A valid Yahoo domain will still return `validSmtp` true because their SMTP servers do not allow verifying if a mailbox exists.
|
74 |
|
75 | ## Configuration options
|
76 | ### `timeout`
|
77 | Set a timeout in seconds for the smtp connection. Default: `10000`.
|
78 | ### `verifyMx`
|
79 | Enable or disable domain checking. This is done in two steps:
|
80 | 1. Verify that the domain does indeed exist;
|
81 | 2. Verify that the domain has valid MX records.
|
82 | Default: `false`.
|
83 | ### `verifySmtp`
|
84 | Enable or disable mailbox checking. Only a few SMTP servers allow this, and even then whether it works depends on your IP's reputation with those servers. This library performs a best effort validation:
|
85 | * It returns `null` for Yahoo addresses, for failed connections, for unknown SMTP errors.
|
86 | * It returns `true` for valid SMTP responses.
|
87 | * It returns `false` for SMTP errors specific to the address's formatting or mailbox existence.
|
88 | Default: `false`.
|
89 |
|
90 | ### Disposable email providers database ( ✅ Always Updated )
|
91 | [Disposable email providers](./src/disposable-email-providers.json)
|
92 |
|
93 | ### Free email providers database ( ✅ Always Updated )
|
94 | [Free email providers](./src/free-email-providers.json)
|
95 |
|
96 | ## Testing
|
97 | ```bash
|
98 | yarn test
|
99 | ```
|
100 |
|
101 | ## Contributing
|
102 | Please feel free to open an issue or create a pull request and fix bugs or add features, All contributions are welcome. Thank you!
|
103 |
|
104 | ## LICENSE [MIT](LICENSE.md)
|