email-bounce-parser 1.0.18 → 1.0.19
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 +24 -12
- package/package.json +1 -1
package/lib/parser.js
CHANGED
|
@@ -110,12 +110,13 @@ var REGEXES = {
|
|
|
110
110
|
|
|
111
111
|
recipient : [
|
|
112
112
|
/the following addresses had permanent fatal errors (?:.*?)\s\<(.+?)\>/i,
|
|
113
|
+
/there was a temporary problem delivering your message to (.+?). Gmail will retry/i,
|
|
113
114
|
/the following message to \<(.+?)\> was undeliverable/i,
|
|
114
115
|
/to the following addresses:\s*(.+)/i,
|
|
115
|
-
/^\<(.+?)\>:/m,
|
|
116
|
-
/^(.+?)\s?(?:\s\(.*?\))?\n?\s*[\[|<]mailto\:(.+?)[\]|>]/mi, // "john@acme.com<mailto:john@acme.com>" or "john@acme.com[mailto:john@acme.com]" or "john@acme.com (john@acme.com)<mailto:john@acme.com>"
|
|
117
116
|
/^your message wasn't delivered to (.+?)\s/mi, // "Your message wasn't delivered to john@acme.com"
|
|
118
117
|
/^your message to (.+?) couldn\'t/mi, // "Your message to john@acme.com couldn't"
|
|
118
|
+
/^(.+?)\s?(?:\s\(.*?\))?\n?\s*[\[|<]mailto\:(.+?)[\]|>]/mi, // "john@acme.com<mailto:john@acme.com>" or "john@acme.com[mailto:john@acme.com]" or "john@acme.com (john@acme.com)<mailto:john@acme.com>"
|
|
119
|
+
/^\<(.+?)\>:/m,
|
|
119
120
|
/\<(.+?)\> \(expanded from \<.+?\>\)\:/, // "<john@acme.com> (expanded from <john@digiflex.com>): "
|
|
120
121
|
/\<(.+?)\>:/ // "<john@acme.com>:"
|
|
121
122
|
],
|
|
@@ -147,6 +148,10 @@ var REGEXES = {
|
|
|
147
148
|
/(out of storage|(?:mailbox (?:is )?full)|(?:user (?:is )?over quota))/i // "user is over quota" (iCloud)
|
|
148
149
|
],
|
|
149
150
|
|
|
151
|
+
enhanced_types_reputation : [
|
|
152
|
+
/(rate limited due to IP reputation)/i
|
|
153
|
+
],
|
|
154
|
+
|
|
150
155
|
error_code : [
|
|
151
156
|
/(\d{3})[\s\-](\d\.\d\.\d{1,3})/, // "550 5.4.1" or "550-5.4.1" or "550-5.4.11" or "550-5.4.110"
|
|
152
157
|
/(\d{3})\-\'(\d\.\d\.\d{1,3})/, // "550-'5.4.1" or "550-'5.4.11" or "550-'5.4.110"
|
|
@@ -299,21 +304,22 @@ class Parser {
|
|
|
299
304
|
_permanent = true;
|
|
300
305
|
}
|
|
301
306
|
|
|
302
|
-
// Make sure the bounce is actually permanent
|
|
303
|
-
if (_permanent === true) {
|
|
304
|
-
var _match = this.__regexes.temporary_safe.match(str);
|
|
305
|
-
|
|
306
|
-
if (_match && _match.length > 1) {
|
|
307
|
-
_temporary = true;
|
|
308
|
-
_permanent = false;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
307
|
if (_code.basic) {
|
|
313
308
|
_type = ERROR_CODES_TYPES[_code.basic] || null
|
|
314
309
|
}
|
|
315
310
|
}
|
|
316
311
|
|
|
312
|
+
// In cases where the bounce is detected as permanent, or the \
|
|
313
|
+
// temporary / permanent status is still unclear, run additional detection
|
|
314
|
+
if (_permanent === true || (_temporary === false && _permanent === false)) {
|
|
315
|
+
var _match = this.__regexes.temporary_safe.match(str);
|
|
316
|
+
|
|
317
|
+
if (_match && _match.length > 1) {
|
|
318
|
+
_temporary = true;
|
|
319
|
+
_permanent = false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
317
323
|
// No label detected? Probably because there's no error code
|
|
318
324
|
if (!_label) {
|
|
319
325
|
// Attempt a lax check
|
|
@@ -409,6 +415,12 @@ class Parser {
|
|
|
409
415
|
_type = "mailbox_full";
|
|
410
416
|
}
|
|
411
417
|
|
|
418
|
+
_match = loopRegexes(this.__regexes.enhanced_types_reputation, str);
|
|
419
|
+
|
|
420
|
+
if (!_type && _match && _match.length > 1) {
|
|
421
|
+
_type = "reputation";
|
|
422
|
+
}
|
|
423
|
+
|
|
412
424
|
// Detect enhanced-type from enhanced error code
|
|
413
425
|
// Notice: this is done as a last resort, as sometimes enhanced code \
|
|
414
426
|
// doesn't clearly convey the actual error
|