Skip to content

Commit 4823377

Browse files
Updated to call MailboxValidator v2 APIs
1 parent d961723 commit 4823377

File tree

5 files changed

+224
-146
lines changed

5 files changed

+224
-146
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 MailboxValidator.com
3+
Copyright (c) 2023 MailboxValidator.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 65 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,33 @@ Usage for validation email
3030
==========================
3131

3232
```javascript
33-
var mbv = require("mailboxvalidator-nodejs");
33+
let mbv = require("mailboxvalidator-nodejs");
3434

3535
mbv.MailboxValidator_init("YOUR_API_KEY");
3636

37-
mbv.MailboxValidator_single_query("[email protected]", mbv_read_single);
38-
39-
function mbv_read_single(err, res, data) {
40-
if (!err && res.statusCode == 200) {
41-
console.log("email_address: " + data.email_address);
42-
console.log("domain: " + data.domain);
43-
console.log("is_free: " + data.is_free);
44-
console.log("is_syntax: " + data.is_syntax);
45-
console.log("is_domain: " + data.is_domain);
46-
console.log("is_smtp: " + data.is_smtp);
47-
console.log("is_verified: " + data.is_verified);
48-
console.log("is_server_down: " + data.is_server_down);
49-
console.log("is_greylisted: " + data.is_greylisted);
50-
console.log("is_disposable: " + data.is_disposable);
51-
console.log("is_suppressed: " + data.is_suppressed);
52-
console.log("is_role: " + data.is_role);
53-
console.log("is_high_risk: " + data.is_high_risk);
54-
console.log("is_catchall: " + data.is_catchall);
55-
console.log("mailboxvalidator_score: " + data.mailboxvalidator_score);
56-
console.log("time_taken: " + data.time_taken);
57-
console.log("status: " + data.status);
58-
console.log("credits_available: " + data.credits_available);
59-
console.log("error_code: " + data.error_code);
60-
console.log("error_message: " + data.error_message);
61-
}
62-
}
37+
mbv.MailboxValidator_single_query("[email protected]")
38+
.then((data) => {
39+
console.log("email_address: " + data.email_address);
40+
console.log("domain: " + data.domain);
41+
console.log("is_free: " + data.is_free);
42+
console.log("is_syntax: " + data.is_syntax);
43+
console.log("is_domain: " + data.is_domain);
44+
console.log("is_smtp: " + data.is_smtp);
45+
console.log("is_verified: " + data.is_verified);
46+
console.log("is_server_down: " + data.is_server_down);
47+
console.log("is_greylisted: " + data.is_greylisted);
48+
console.log("is_disposable: " + data.is_disposable);
49+
console.log("is_suppressed: " + data.is_suppressed);
50+
console.log("is_role: " + data.is_role);
51+
console.log("is_high_risk: " + data.is_high_risk);
52+
console.log("is_catchall: " + data.is_catchall);
53+
console.log("mailboxvalidator_score: " + data.mailboxvalidator_score);
54+
console.log("time_taken: " + data.time_taken);
55+
console.log("status: " + data.status);
56+
console.log("credits_available: " + data.credits_available);})
57+
.catch((error) => {
58+
console.log(error)
59+
});
6360
```
6461

6562
Functions
@@ -69,9 +66,9 @@ Functions
6966

7067
Creates a new instance of the MailboxValidator object with the API key.
7168

72-
### MailboxValidator_single_query(email_address, callback_function)
69+
### MailboxValidator_single_query(email_address)
7370

74-
Performs email validation on the supplied email address and a callback function.
71+
Performs email validation on the supplied email address and returns a Promise.
7572

7673
Result Fields
7774
=============
@@ -88,73 +85,73 @@ The domain of the email address.
8885

8986
Whether the email address is from a free email provider like Gmail or Hotmail.
9087

91-
Return values: True, False
88+
Return values: true, false
9289

9390
### is_syntax
9491

9592
Whether the email address is syntactically correct.
9693

97-
Return values: True, False
94+
Return values: true, false
9895

9996
### is_domain
10097

10198
Whether the email address has a valid MX record in its DNS entries.
10299

103-
Return values: True, False, -   (- means not applicable)
100+
Return values: true, false, null   (null means not applicable)
104101

105102
### is_smtp
106103

107104
Whether the mail servers specified in the MX records are responding to connections.
108105

109-
Return values: True, False, -   (- means not applicable)
106+
Return values: true, false, null   (null means not applicable)
110107

111108
### is_verified
112109

113110
Whether the mail server confirms that the email address actually exist.
114111

115-
Return values: True, False, -   (- means not applicable)
112+
Return values: true, false, null   (null means not applicable)
116113

117114
### is_server_down
118115

119116
Whether the mail server is currently down or unresponsive.
120117

121-
Return values: True, False, -   (- means not applicable)
118+
Return values: true, false, null   (null means not applicable)
122119

123120
### is_greylisted
124121

125122
Whether the mail server employs greylisting where an email has to be sent a second time at a later time.
126123

127-
Return values: True, False, -   (- means not applicable)
124+
Return values: true, false, null   (null means not applicable)
128125

129126
### is_disposable
130127

131128
Whether the email address is a temporary one from a disposable email provider.
132129

133-
Return values: True, False, -   (- means not applicable)
130+
Return values: true, false, null   (null means not applicable)
134131

135132
### is_suppressed
136133

137134
Whether the email address is in our blacklist.
138135

139-
Return values: True, False, -   (- means not applicable)
136+
Return values: true, false, null   (null means not applicable)
140137

141138
### is_role
142139

143140
Whether the email address is a role-based email address like [email protected] or [email protected].
144141

145-
Return values: True, False, -   (- means not applicable)
142+
Return values: true, false, null   (null means not applicable)
146143

147144
### is_high_risk
148145

149146
Whether the email address contains high risk keywords.
150147

151-
Return values: True, False, -   (- means not applicable)
148+
Return values: true, false, null   (null means not applicable)
152149

153150
### is_catchall
154151

155152
Whether the email address is a catch-all address.
156153

157-
Return values: True, False, Unknown, -   (- means not applicable)
154+
Return values: true, false, null   (null means not applicable)
158155

159156
### mailboxvalidator_score
160157

@@ -170,40 +167,29 @@ The time taken to get the results in seconds.
170167

171168
Whether our system think the email address is valid based on all the previous fields.
172169

173-
Return values: True, False
170+
Return values: true, false
174171

175172
### credits_available
176173

177174
The number of credits left to perform validations.
178175

179-
### error_code
180-
181-
The error code if there is any error. See error table below.
182-
183-
### error_message
184-
185-
The error message if there is any error. See error table below.
186-
187-
188176
Usage for checking if the email is from a disposable email provider
189177
===================================================================
190178

191179
```javascript
192-
var mbv = require("mailboxvalidator-nodejs");
180+
let mbv = require("mailboxvalidator-nodejs");
193181

194182
mbv.MailboxValidator_init("YOUR_API_KEY");
195183

196-
mbv.MailboxValidator_disposable_email("[email protected]", mbv_read_disposable);
197-
198-
function mbv_read_disposable(err, res, data) {
199-
if (!err && res.statusCode == 200) {
200-
console.log("email_address: " + data.email_address);
201-
console.log("is_disposable: " + data.is_disposable);
202-
console.log("credits_available: " + data.credits_available);
203-
console.log("error_code: " + data.error_code);
204-
console.log("error_message: " + data.error_message);
205-
}
206-
}
184+
mbv.MailboxValidator_disposable_email("[email protected]")
185+
.then((data) => {
186+
console.log("email_address: " + data.email_address);
187+
console.log("is_disposable: " + data.is_disposable);
188+
console.log("credits_available: " + data.credits_available);
189+
})
190+
.catch((error) => {
191+
console.log(error)
192+
});
207193
```
208194

209195
Functions
@@ -213,9 +199,9 @@ Functions
213199

214200
Creates a new instance of the MailboxValidator object with the API key.
215201

216-
### MailboxValidator_disposable_email(email_address, callback_function)
202+
### MailboxValidator_disposable_email(email_address)
217203

218-
Performs disposable email check on the supplied email address and a callback function.
204+
Performs disposable email check on the supplied email address and returns a Promise.
219205

220206
Result Fields
221207
=============
@@ -228,40 +214,28 @@ The input email address.
228214

229215
Whether the email address is a temporary one from a disposable email provider.
230216

231-
Return values: True, False
217+
Return values: true, false
232218

233219
### credits_available
234220

235221
The number of credits left to perform validations.
236222

237-
### error_code
238-
239-
The error code if there is any error. See error table below.
240-
241-
### error_message
242-
243-
The error message if there is any error. See error table below.
244-
245-
246223
Usage for checking if the email is from a free email provider
247224
=============================================================
248225

249226
```javascript
250-
var mbv = require("mailboxvalidator-nodejs");
227+
let mbv = require("mailboxvalidator-nodejs");
251228

252229
mbv.MailboxValidator_init("YOUR_API_KEY");
253230

254-
mbv.MailboxValidator_free_email("[email protected]", mbv_read_free);
255-
256-
function mbv_read_free(err, res, data) {
257-
if (!err && res.statusCode == 200) {
258-
console.log("email_address: " + data.email_address);
259-
console.log("is_free: " + data.is_free);
260-
console.log("credits_available: " + data.credits_available);
261-
console.log("error_code: " + data.error_code);
262-
console.log("error_message: " + data.error_message);
263-
}
264-
}
231+
mbv.MailboxValidator_free_email("[email protected]")
232+
.then((data) => {
233+
console.log("email_address: " + data.email_address);
234+
console.log("is_free: " + data.is_free);
235+
console.log("credits_available: " + data.credits_available);})
236+
.catch((error) => {
237+
console.log(error)
238+
});
265239
```
266240

267241
Functions
@@ -271,9 +245,9 @@ Functions
271245

272246
Creates a new instance of the MailboxValidator object with the API key.
273247

274-
### MailboxValidator_free_email(email_address, callback_function)
248+
### MailboxValidator_free_email(email_address)
275249

276-
Performs free email check on the supplied email address and a callback function.
250+
Performs free email check on the supplied email address and returns a Promise.
277251

278252
Result Fields
279253
=============
@@ -286,35 +260,14 @@ The input email address.
286260

287261
Whether the email address is from a free email provider like Gmail or Hotmail.
288262

289-
Return values: True, False
263+
Return values: true, false
290264

291265
### credits_available
292266

293267
The number of credits left to perform validations.
294268

295-
### error_code
296-
297-
The error code if there is any error. See error table below.
298-
299-
### error_message
300-
301-
The error message if there is any error. See error table below.
302-
303-
304-
Errors
305-
======
306-
307-
| error_code | error_message |
308-
| ---------- | ------------- |
309-
| 100 | Missing parameter. |
310-
| 101 | API key not found. |
311-
| 102 | API key disabled. |
312-
| 103 | API key expired. |
313-
| 104 | Insufficient credits. |
314-
| 105 | Unknown error. |
315-
316269

317270
Copyright
318271
=========
319272

320-
Copyright (C) 2020 by MailboxValidator.com, [email protected]
273+
Copyright (C) 2023 by MailboxValidator.com, [email protected]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mailboxvalidator-nodejs",
3-
"version": "1.1.3",
3+
"version": "2.0.0",
44
"description": "MailboxValidator Node.js module enable users to block disposal email, detect free email and validate if an email is valid",
55
"keywords": ["email validation", "disposable", "invalid email", "free email", "fake email"],
66
"homepage": "https://www.mailboxvalidator.com/nodejs",

0 commit comments

Comments
 (0)