email-bounce-parser 1.0.10 → 1.0.12
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 +69 -29
- package/package.json +1 -1
package/lib/parser.js
CHANGED
|
@@ -9,16 +9,40 @@ var ERROR_CODES_TYPES = {
|
|
|
9
9
|
"421 4.3.0" : "temporary_system_problem",
|
|
10
10
|
"421 4.4.5" : "server_busy",
|
|
11
11
|
"432 4.7.12" : "password_needed",
|
|
12
|
-
"450" : "
|
|
13
|
-
"
|
|
14
|
-
"
|
|
12
|
+
"450" : "action_not_taken_mailbox_unavailable",
|
|
13
|
+
"450 4.2.1" : "action_not_taken_mailbox_rate_limited",
|
|
14
|
+
"451 4.4.2" : "timeout",
|
|
15
|
+
"451" : "action_aborted_local_error",
|
|
16
|
+
"451 4.5.0" : "smtp_protocol_violation_rfc_2821",
|
|
17
|
+
"452" : "action_not_taken_insufficient_system_storage",
|
|
18
|
+
"452 4.2.2" : "mailbox_over_quota",
|
|
19
|
+
"454" : "smtp_protocol_violation_rfc_3207",
|
|
20
|
+
"454 4.5.0" : "smtp_protocol_violation_rfc_3207",
|
|
21
|
+
"454 4.7.0" : "authentication_issue",
|
|
22
|
+
"455" : "server_unable_to_accommodate_parameters",
|
|
23
|
+
"500" : "syntax_error",
|
|
24
|
+
"501" : "syntax_error_parameters",
|
|
25
|
+
"501 5.5.2" : "response_decode_error",
|
|
26
|
+
"501 5.5.4" : "invalid_helo_ehlo",
|
|
27
|
+
"502" : "command_not_implemented",
|
|
15
28
|
"503" : "bad_commands_sequence",
|
|
29
|
+
"503 5.7.0" : "no_identity_changes_permitted",
|
|
30
|
+
"504" : "parameter_not_implemented",
|
|
31
|
+
"504 5.7.4" : "unrecognized_authentication_type",
|
|
32
|
+
"530 5.5.1" : "authentication_required",
|
|
16
33
|
"550" : "action_not_taken",
|
|
17
34
|
"550 5.1.1" : "no_such_recipient",
|
|
18
35
|
"550 5.2.1" : "recipient_disabled_or_recipient_rate_limited",
|
|
19
36
|
"550 5.7.1" : "spam_content",
|
|
37
|
+
"551" : "user_not_local",
|
|
38
|
+
"552" : "action_aborted_exceeded_storage_allocation",
|
|
39
|
+
"552 5.2.2" : "mailbox_over_quota",
|
|
40
|
+
"552 5.2.3" : "message_size_limit",
|
|
41
|
+
"553" : "action_not_taken_mailbox_name_not_allowed",
|
|
20
42
|
"554" : "transaction_failed",
|
|
21
43
|
"554 5.7.1" : "spam_content",
|
|
44
|
+
"555" : "parameters_not_recognized",
|
|
45
|
+
"555 5.5.2" : "syntax_error"
|
|
22
46
|
};
|
|
23
47
|
|
|
24
48
|
var REGEXES = {
|
|
@@ -44,7 +68,8 @@ var REGEXES = {
|
|
|
44
68
|
],
|
|
45
69
|
|
|
46
70
|
email_server : [
|
|
47
|
-
/host (\S+)\[([\d\.]+)\](?:\:(\d+)\:)? said/m,
|
|
71
|
+
/host (\S+)\[([\d\.]+)\](?:\:(\d+)\:)? (?:said|refused to talk)/m,
|
|
72
|
+
/^(\S+) rejected your message/m,
|
|
48
73
|
/\: connect to (.+)\[(.+)\](?:\:(\d+)\:)?/m,
|
|
49
74
|
/Name service error for name\=(\S+)\s/m,
|
|
50
75
|
/RCPT TO\:\<(.+?)\>/m,
|
|
@@ -55,17 +80,20 @@ var REGEXES = {
|
|
|
55
80
|
error : [
|
|
56
81
|
/said\: (\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+) \(in reply to/m,
|
|
57
82
|
/said\: (\d{3}(?:[\s\-]\d\.\d\.\d\d?)?)-(.+)/m,
|
|
83
|
+
/(\d{3}\-\'\d\.\d\.\d\d?) (.+)/m,
|
|
58
84
|
/LMTP error after (?:.+?)\:\<.+?\>\: (\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) <.+?\>(.+)$/m,
|
|
59
85
|
/Remote Server returned \'(\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)\'/m,
|
|
60
86
|
/The response from the remote server was:\s(\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)/m,
|
|
61
87
|
/refused to talk to me\: (\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)/m,
|
|
62
|
-
/
|
|
63
|
-
/
|
|
64
|
-
/(\d{3}
|
|
88
|
+
/(?:error|reason)\:\s*?(\d{3}(?:[\s\-]\d\.\d\.\d\d?)?) (.+)/mi,
|
|
89
|
+
/(\d{3}[\s\-]\d\.\d\.\d\d?)/m,
|
|
90
|
+
/(\d{3}\-\'\d\.\d\.\d\d?)/m,
|
|
65
91
|
],
|
|
66
92
|
|
|
67
93
|
recipient : [
|
|
68
94
|
/The following addresses had permanent fatal errors (?:.*?)\s\<(.+?)\>/,
|
|
95
|
+
/The following message to \<(.+?)\> was undeliverable/,
|
|
96
|
+
/to the following addresses:\s*(.+)/,
|
|
69
97
|
/^\<(.+?)\>:/m,
|
|
70
98
|
/^(.+?)\s?\n?\s*[\[|<]mailto\:(.+?)[\]|>]/m,
|
|
71
99
|
/^Your message wasn't delivered to (.+?)\s/m,
|
|
@@ -74,14 +102,15 @@ var REGEXES = {
|
|
|
74
102
|
],
|
|
75
103
|
|
|
76
104
|
temporary_safe : /(temporary|temporarily)/i,
|
|
77
|
-
blocked : /((?:is listed)blocked|banned|denied|dnsbl)/i,
|
|
105
|
+
blocked : /((?:is listed)|blocked|banned|denied|dnsbl)/i,
|
|
78
106
|
spam : /(spam)/i,
|
|
79
107
|
|
|
80
108
|
enhanced_types_no_such_recipient : [
|
|
81
109
|
/(recipient address rejected: access denied)/i, // Outlook DBEB for invalid addresses
|
|
82
110
|
/(invalid mailbox)/i,
|
|
83
111
|
/(do(e)?sn\'t exist)/i, // Some Chinese SMTP return "dosn't" instead of "doesn't"
|
|
84
|
-
/(
|
|
112
|
+
/(user (?:.+?) does not exist)/i,
|
|
113
|
+
/((?:account|user|mailbox) (?:is )?(?:terminated|disabled|inactive|not found|unavailable|invalid))/i
|
|
85
114
|
],
|
|
86
115
|
|
|
87
116
|
enhanced_types_server_unknown : [
|
|
@@ -92,13 +121,14 @@ var REGEXES = {
|
|
|
92
121
|
/(timeout|timed[\s\-]out)/i
|
|
93
122
|
],
|
|
94
123
|
|
|
95
|
-
|
|
96
|
-
/(
|
|
97
|
-
/(\d{3})/
|
|
124
|
+
enhanced_types_mailbox_full : [
|
|
125
|
+
/(out of storage|(?:mailbox (?:is )?full)|(?:user (?:is )?over quota))/i
|
|
98
126
|
],
|
|
99
127
|
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
error_code : [
|
|
129
|
+
/(\d{3})[\s\-](\d\.\d\.\d)/, // "550 5.4.1" or "550-5.4.1"
|
|
130
|
+
/(\d{3})\-\'(\d\.\d\.\d)/, // "550-'5.4.1"
|
|
131
|
+
/(\d{3})/ // "550"
|
|
102
132
|
]
|
|
103
133
|
};
|
|
104
134
|
|
|
@@ -318,26 +348,36 @@ class Parser {
|
|
|
318
348
|
_spam = false;
|
|
319
349
|
|
|
320
350
|
if (code.basic) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
} else {
|
|
324
|
-
var _match = loopRegexes(this.__regexes.enhanced_types_no_such_recipient, str);
|
|
351
|
+
// Detect enhanced-type from bounce content
|
|
352
|
+
var _match = loopRegexes(this.__regexes.enhanced_types_no_such_recipient, str);
|
|
325
353
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
354
|
+
if (_match && _match.length > 1) {
|
|
355
|
+
_type = "no_such_recipient";
|
|
356
|
+
}
|
|
329
357
|
|
|
330
|
-
|
|
358
|
+
_match = loopRegexes(this.__regexes.enhanced_types_server_unknown, str);
|
|
331
359
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
360
|
+
if (!_type && _match && _match.length > 1) {
|
|
361
|
+
_type = "server_unknown";
|
|
362
|
+
}
|
|
335
363
|
|
|
336
|
-
|
|
364
|
+
_match = loopRegexes(this.__regexes.enhanced_types_server_timeout, str);
|
|
337
365
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
366
|
+
if (!_type && _match && _match.length > 1) {
|
|
367
|
+
_type = "server_timeout";
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
_match = loopRegexes(this.__regexes.enhanced_types_mailbox_full, str);
|
|
371
|
+
|
|
372
|
+
if (!_type && _match && _match.length > 1) {
|
|
373
|
+
_type = "mailbox_full";
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Detect enhanced-type from enhanced error code
|
|
377
|
+
// Notice: this is done as a last resort, as sometimes enhanced code \
|
|
378
|
+
// doesn't clearly convey the actual error
|
|
379
|
+
if (!_type && _match && code.enhanced) {
|
|
380
|
+
_type = ERROR_CODES_TYPES[`${code.basic} ${code.enhanced}`] || null;
|
|
341
381
|
}
|
|
342
382
|
}
|
|
343
383
|
|