email-bounce-parser 1.0.1 → 1.0.3
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/README.md +2 -0
- package/lib/parser.js +42 -8
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/parser.js
CHANGED
|
@@ -54,9 +54,11 @@ var REGEXES = {
|
|
|
54
54
|
|
|
55
55
|
error : [
|
|
56
56
|
/said\: (\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+) \(in reply to/m,
|
|
57
|
+
/said\: (\d{3}(?:[\s\-]\d\.\d\.\d\d?)?)-(.+)/m,
|
|
57
58
|
/LMTP error after (?:.+?)\:\<.+?\>\: (\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) <.+?\>(.+)$/m,
|
|
58
59
|
/Remote Server returned \'(\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)\'/m,
|
|
59
60
|
/The response from the remote server was:\s(\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)/m,
|
|
61
|
+
/refused to talk to me\: (\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)/m,
|
|
60
62
|
/Error\:\s*?(\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)/m,
|
|
61
63
|
/reason: (\d{3}[\s\-]\d\.\d\.\d\d?) (.+)/m,
|
|
62
64
|
/(\d{3}[\s\-]\d\.\d\.\d\d?)/m
|
|
@@ -71,6 +73,10 @@ var REGEXES = {
|
|
|
71
73
|
/\<(.+?)\>:/
|
|
72
74
|
],
|
|
73
75
|
|
|
76
|
+
temporary_safe : /(temporary|temporarily)/i,
|
|
77
|
+
blocked : /((?:is listed)blocked|banned|denied|dnsbl)/i,
|
|
78
|
+
spam : /(spam)/i,
|
|
79
|
+
|
|
74
80
|
error_code : [
|
|
75
81
|
/(\d{3})[\s\-](\d\.\d\.\d)/,
|
|
76
82
|
/(\d{3})/
|
|
@@ -217,13 +223,23 @@ class Parser {
|
|
|
217
223
|
if (_match && _match.length > 1) {
|
|
218
224
|
_code = this.__parseErrorCode(_match[1]);
|
|
219
225
|
_label = trimString(_match[2]);
|
|
220
|
-
}
|
|
221
226
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
+
// Check temporary / permanent
|
|
228
|
+
if (_code.basic[0] === "4") {
|
|
229
|
+
_temporary = true;
|
|
230
|
+
} else if (_code.basic[0] === "5") {
|
|
231
|
+
_permanent = true;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Make sure the bounce is actually permanent
|
|
235
|
+
if (_permanent === true) {
|
|
236
|
+
var _match = this.__regexes.temporary_safe.match(str);
|
|
237
|
+
|
|
238
|
+
if (_match && _match.length > 1) {
|
|
239
|
+
_temporary = true;
|
|
240
|
+
_permanent = false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
227
243
|
}
|
|
228
244
|
|
|
229
245
|
// Extract further data
|
|
@@ -282,14 +298,32 @@ class Parser {
|
|
|
282
298
|
* @return {object} The error data
|
|
283
299
|
*/
|
|
284
300
|
__parseErrorData(str, code, label) {
|
|
285
|
-
var _type = null
|
|
301
|
+
var _type = null,
|
|
302
|
+
_blocked = false,
|
|
303
|
+
_spam = false;
|
|
286
304
|
|
|
287
305
|
if (code.basic && code.enhanced) {
|
|
288
306
|
_type = ERROR_CODES_TYPES[`${code.basic} ${code.enhanced}`] || null;
|
|
289
307
|
}
|
|
290
308
|
|
|
309
|
+
// Check if blocked
|
|
310
|
+
var _blocked_match = this.__regexes.blocked.match(str);
|
|
311
|
+
|
|
312
|
+
if (_blocked_match && _blocked_match.length > 1) {
|
|
313
|
+
_blocked = true;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Check if spam
|
|
317
|
+
var _spam_match = this.__regexes.spam.match(str);
|
|
318
|
+
|
|
319
|
+
if (_spam_match && _spam_match.length > 1) {
|
|
320
|
+
_spam = true;
|
|
321
|
+
}
|
|
322
|
+
|
|
291
323
|
return {
|
|
292
|
-
type
|
|
324
|
+
type : _type,
|
|
325
|
+
blocked : _blocked,
|
|
326
|
+
spam : _spam
|
|
293
327
|
}
|
|
294
328
|
}
|
|
295
329
|
|