email-bounce-parser 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parser.js +45 -28
- package/package.json +1 -1
package/lib/parser.js
CHANGED
|
@@ -87,7 +87,11 @@ var REGEXES = {
|
|
|
87
87
|
/refused to talk to me\: (\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)/m,
|
|
88
88
|
/(?:error|reason)\:\s*?(\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)/mi,
|
|
89
89
|
/(\d{3}[\s\-]\d\.\d\.\d\d?)/m,
|
|
90
|
-
/(\d{3}\-\'\d\.\d\.\d\d?)/m
|
|
90
|
+
/(\d{3}\-\'\d\.\d\.\d\d?)/m
|
|
91
|
+
],
|
|
92
|
+
|
|
93
|
+
error_lax : [
|
|
94
|
+
/(^\<.+?\>:.+)/m
|
|
91
95
|
],
|
|
92
96
|
|
|
93
97
|
recipient : [
|
|
@@ -107,10 +111,10 @@ var REGEXES = {
|
|
|
107
111
|
|
|
108
112
|
enhanced_types_no_such_recipient : [
|
|
109
113
|
/(recipient address rejected: access denied)/i, // Outlook DBEB for invalid addresses
|
|
110
|
-
/(invalid mailbox)/i,
|
|
114
|
+
/((?:terminated|disabled|inactive|not found|unavailable|invalid) (?:account|user|mailbox|recipient))/i,
|
|
111
115
|
/(do(e)?sn\'t exist)/i, // Some Chinese SMTP return "dosn't" instead of "doesn't"
|
|
112
116
|
/(user (?:.+?) does not exist)/i,
|
|
113
|
-
/((?:account|user|mailbox) (?:is )?(?:terminated|disabled|inactive|not found|unavailable|invalid))/i
|
|
117
|
+
/((?:account|user|mailbox|recipient) (?:.+@.+ )?(?:is )?(?:terminated|disabled|inactive|not found|unavailable|invalid))/i
|
|
114
118
|
],
|
|
115
119
|
|
|
116
120
|
enhanced_types_server_unknown : [
|
|
@@ -260,6 +264,7 @@ class Parser {
|
|
|
260
264
|
enhanced : null
|
|
261
265
|
},
|
|
262
266
|
_label = null,
|
|
267
|
+
_type = null,
|
|
263
268
|
_temporary = false,
|
|
264
269
|
_permanent = false;
|
|
265
270
|
|
|
@@ -285,6 +290,20 @@ class Parser {
|
|
|
285
290
|
_permanent = false;
|
|
286
291
|
}
|
|
287
292
|
}
|
|
293
|
+
|
|
294
|
+
if (_code.basic) {
|
|
295
|
+
_type = ERROR_CODES_TYPES[_code.basic] || null
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// No label detected? Probably because there's no error code
|
|
300
|
+
if (!_label) {
|
|
301
|
+
// Attempt a lax check
|
|
302
|
+
var _match = loopRegexes(this.__regexes.error_lax, str);
|
|
303
|
+
|
|
304
|
+
if (_match && _match.length > 1) {
|
|
305
|
+
_label = trimString(_match[1]);
|
|
306
|
+
}
|
|
288
307
|
}
|
|
289
308
|
|
|
290
309
|
// Extract further data
|
|
@@ -294,7 +313,7 @@ class Parser {
|
|
|
294
313
|
code : _code,
|
|
295
314
|
label : _label,
|
|
296
315
|
|
|
297
|
-
type :
|
|
316
|
+
type : _type,
|
|
298
317
|
|
|
299
318
|
temporary : _temporary,
|
|
300
319
|
permanent : _permanent,
|
|
@@ -347,38 +366,36 @@ class Parser {
|
|
|
347
366
|
_blocked = false,
|
|
348
367
|
_spam = false;
|
|
349
368
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
var _match = loopRegexes(this.__regexes.enhanced_types_no_such_recipient, str);
|
|
369
|
+
// Detect enhanced-type from bounce content
|
|
370
|
+
var _match = loopRegexes(this.__regexes.enhanced_types_no_such_recipient, str);
|
|
353
371
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
372
|
+
if (_match && _match.length > 1) {
|
|
373
|
+
_type = "no_such_recipient";
|
|
374
|
+
}
|
|
357
375
|
|
|
358
|
-
|
|
376
|
+
_match = loopRegexes(this.__regexes.enhanced_types_server_unknown, str);
|
|
359
377
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
378
|
+
if (!_type && _match && _match.length > 1) {
|
|
379
|
+
_type = "server_unknown";
|
|
380
|
+
}
|
|
363
381
|
|
|
364
|
-
|
|
382
|
+
_match = loopRegexes(this.__regexes.enhanced_types_server_timeout, str);
|
|
365
383
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
384
|
+
if (!_type && _match && _match.length > 1) {
|
|
385
|
+
_type = "server_timeout";
|
|
386
|
+
}
|
|
369
387
|
|
|
370
|
-
|
|
388
|
+
_match = loopRegexes(this.__regexes.enhanced_types_mailbox_full, str);
|
|
371
389
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
390
|
+
if (!_type && _match && _match.length > 1) {
|
|
391
|
+
_type = "mailbox_full";
|
|
392
|
+
}
|
|
375
393
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
394
|
+
// Detect enhanced-type from enhanced error code
|
|
395
|
+
// Notice: this is done as a last resort, as sometimes enhanced code \
|
|
396
|
+
// doesn't clearly convey the actual error
|
|
397
|
+
if (!_type && _match && code.enhanced) {
|
|
398
|
+
_type = ERROR_CODES_TYPES[`${code.basic} ${code.enhanced}`] || null;
|
|
382
399
|
}
|
|
383
400
|
|
|
384
401
|
// Check if blocked
|