Skip to content

Commit eb16913

Browse files
Merge branch 'master' of github.com:crisp-oss/email-bounce-parser
2 parents 7fba22a + 06d5cd7 commit eb16913

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1020
-19
lines changed

lib/parser.js

+18-14
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ var ERROR_CODES_TYPES = {
3535
"550 5.1.1" : "no_such_recipient",
3636
"550 5.2.1" : "recipient_disabled_or_recipient_rate_limited",
3737
"550 5.7.1" : "spam_content",
38+
"550 5.7.26" : "authentication_failure",
3839
"551" : "user_not_local",
3940
"552" : "action_aborted_exceeded_storage_allocation",
4041
"552 5.2.2" : "mailbox_over_quota",
4142
"552 5.2.3" : "message_size_limit",
4243
"553" : "action_not_taken_mailbox_name_not_allowed",
44+
"553 5.1.2" : "no_such_recipient",
4345
"554" : "transaction_failed",
4446
"554 5.7.1" : "spam_content",
4547
"555" : "parameters_not_recognized",
@@ -78,19 +80,20 @@ var REGEXES = {
7880
/Message rejected by\:\s+([\S\.]+?)$/m, // Outlook error
7981
/from (\S+) \[([\d\.]+)\](?:\:(\d+)\:)?/m,
8082
/conversation with (\S+)\[([\d\.]+)\](?:\:(\d+)\:)? timed out/m,
83+
/lost connection with (\S+)\[([\d\.]+)\](?:\:(\d+)\:)?/m, // "lost connection with mx.mail-data.net[134.244.220.69]"
8184
/Generating server: (\S+)(?:\[([\d\.]+)\])?(?:\:(\d+)\:)?/m // "Generating server: PH7PR02MB9549495.namprd02.prod.outlook.com"
8285
],
8386

8487
error : [
85-
/said\: (\d{3}(?:[\s\-]\d\.\d\.\d{1,3})?) (.+) \(in reply to/,
86-
/said\: (\d{3}(?:[\s\-]\d\.\d\.\d{1,3})?)-(.+)/,
88+
/said\: (\d{3}(?:[\s\-\#\']{1,2}\d\.\d\.\d{1,3})?) (.+) \(in reply to/,
89+
/said\: (\d{3}(?:[\s\-\#\']{1,2}\d\.\d\.\d{1,3})?)-(.+)/,
8790
/(\d{3}\-\'\d\.\d\.\d{1,3}) (.+)/,
88-
/LMTP error after .+?\:\<.+?\>\: (\d{3}(?:[\s\-]\d\.\d\.\d{1,3})?) <.+?\>(.+)$/m,
89-
/remote server returned \'(\d{3}(?:[\s\-]\d\.\d\.\d{1,3})?) (.+)\'/i,
90-
/The response from the remote server was:\s(\d{3}(?:[\s\-]\d\.\d\.\d{1,3})?) (.+)/,
91-
/refused to talk to me\: (\d{3}(?:[\s\-]\d\.\d\.\d{1,3})?) (.+)/,
92-
/(?:error|reason)\:\s*?(\d{3}(?:[\s\-]\d\.\d\.\d{1,3})?) (.+)/i,
93-
/(\d{3}[\s\-]\d\.\d\.\d{1,3})/,
91+
/LMTP error after .+?\:\<.+?\>\: (\d{3}(?:[\s\-\#\']{1,2}\d\.\d\.\d{1,3})?) <.+?\>(.+)$/m,
92+
/remote server returned \'(\d{3}(?:[\s\-\#\']{1,2}\d\.\d\.\d{1,3})?) (.+)\'/i,
93+
/The response from the remote server was:\s(\d{3}(?:[\s\-\#\']{1,2}\d\.\d\.\d{1,3})?) (.+)/,
94+
/refused to talk to me\: (\d{3}(?:[\s\-\#\']{1,2}\d\.\d\.\d{1,3})?) (.+)/,
95+
/(?:error|reason)\:\s*?(\d{3}(?:[\s\-\#\']{1,2}\d\.\d\.\d{1,3})?) (.+)/i,
96+
/(\d{3}[\s\-\#\']{1,2}\d\.\d\.\d{1,3})/,
9497
/(\d{3}\-\'\d\.\d\.\d{1,3})/
9598
],
9699

@@ -110,7 +113,7 @@ var REGEXES = {
110113

111114
recipient : [
112115
/the following addresses had permanent fatal errors (?:.*?)\s\<(.+?)\>/i,
113-
/there was a temporary problem delivering your message to (.+?). Gmail will retry/i,
116+
/there was a temporary problem (?:while )?delivering your message to (.+?). Gmail will retry/i,
114117
/the following message to \<(.+?)\> was undeliverable/i,
115118
/to the following addresses:\s*(.+)/i,
116119
/^your message wasn't delivered to (.+?)\s/mi, // "Your message wasn't delivered to [email protected]"
@@ -122,8 +125,8 @@ var REGEXES = {
122125
],
123126

124127
temporary_safe : /(temporary|temporarily)/i,
125-
blocked : /((?:is listed)|blocked|banned|denied|dnsbl)/i,
126-
spam : /(spam)/i,
128+
blocked : /((?:is listed)|blocked|block list|banned|denied|dnsbl)/i,
129+
spam : /(spam|unsolicited)/i,
127130

128131
enhanced_types : {
129132
no_such_recipient : [
@@ -150,13 +153,13 @@ var REGEXES = {
150153
],
151154

152155
reputation : [
153-
/(rate limited due to IP reputation)/i
156+
/(rate limited due to IP reputation)/i,
157+
/(new or untrusted IP)/i
154158
]
155159
},
156160

157161
error_code : [
158-
/(\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"
159-
/(\d{3})\-\'(\d\.\d\.\d{1,3})/, // "550-'5.4.1" or "550-'5.4.11" or "550-'5.4.110"
162+
/(\d{3})[\s\-\#\']{1,2}(\d\.\d\.\d{1,3})/, // "550 5.4.1" or "550 #5.4.1" or "550-5.4.1" or "550-'5.4.1"
160163
/(\d{3})/ // "550"
161164
]
162165
};
@@ -552,6 +555,7 @@ class Parser {
552555
_str = _str.replace(this.__regexes.line_break_double_indent_single, "\n\n");
553556

554557
// Replace single Line-break with regular space
558+
// TODO: re2 doesn't support lookbehinds, so for now we use a pure-JS regex
555559
_str = _str.replace(/(?<!\n)\n(?!\n)/gm, " ");
556560

557561
// Replace long indent with double Line-break

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "email-bounce-parser",
3-
"version": "1.0.20",
3+
"version": "1.0.22",
44
"description": "Parses bounce emails and extract errors",
55
"author": "Eliott Vincent <[email protected]>",
66
"main": "lib/index.js",

test/fixtures/421_4_7_0_deferred.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host mta6.am0.yahoodns.net[76.159.240.37] said: 421
14+
4.7.0 [TSS04] Messages from 39.177.48.16 temporarily deferred due to
15+
unexpected volume or user complaints - 4.16.55.1; see
16+
https://postmaster.yahooinc.com/error-codes (in reply to MAIL FROM command)
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host alt1.gmail-smtp-in.l.google.com[124.215.9.62] said:
14+
450-4.2.1 The user you are trying to contact is receiving mail at a rate
15+
that 450-4.2.1 prevents additional messages from being delivered. Please
16+
resend your 450-4.2.1 message at a later time. If the user is able to
17+
receive mail at that 450-4.2.1 time, your message will be delivered. For
18+
more information, please 450-4.2.1 visit 450 4.2.1
19+
https://support.google.com/mail/?p=ReceivingRate
20+
f15-20020a056402354f00b00548d4febb0bsi965249edd.614 - gsmtp (in reply to
21+
RCPT TO command)

test/fixtures/450_rate_limited.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host mta6.am0.yahoodns.net[76.159.240.27] said: 450 User is
14+
receiving mail too quickly tnmpmscs (in reply to RCPT TO command)
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host mx2.emailsrvr.com[180.166.34.2] said: 451 4.7.1
14+
Received too many messages from a new or untrusted IP: 93.177.84.61
15+
(Z27/6DC2420) (G28) (in reply to RCPT TO command)
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
14+
etzzogal-com0i.mail.protection.outlook.com[140.74.42.63] said: 451 4.7.500
15+
Server busy. Please try again later from [39.177.48.16]. (S77714)
16+
[QE2FRA04FT039.eop-fra04.prod.protection.outlook.com
17+
2023-11-23T18:53:22.058Z 10DSKD34941BC6NE] (in reply to end of DATA
18+
command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host mxb.mailgun.org[43.106.31.24] said:
14+
550 5.0.1 Recipient rejected (in reply to RCPT TO command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host mx1.hc3459-45.iphmx.com[193.183.64.148] said:
14+
550 #5.1.0 Address rejected. (in reply to RCPT TO command)

test/fixtures/550_5_7_1_blocked.txt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
14+
outlook-com.olc.protection.outlook.com[140.74.15.33] said: 550 5.7.1
15+
Unfortunately, messages from [31.57.142.204] weren't sent. Please contact
16+
your Internet service provider since part of their network is on our block
17+
list (S3140). You can also refer your provider to
18+
http://mail.live.com/mail/troubleshooting.aspx#errors.
19+
[WP1FDK33EO054.eop-nam02.prod.protection.outlook.com
20+
2023-01-01T00:00:00.001Z 03SDKS32D1WER234] (in reply to MAIL FROM command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
14+
gmail-smtp-in.l.google.com[124.205.72.62] said: 550-5.7.1 [93.177.87.181
15+
19] Gmail has detected that this message is likely 550-5.7.1 suspicious due
16+
to the very low reputation of the sending domain. To 550-5.7.1 best protect
17+
our users from spam, the message has been blocked. 550-5.7.1 Please visit
18+
550 5.7.1 https://support.google.com/mail/answer/188131 for more
19+
information. h6-20020a05640250c600b0054ab00d6afesi892868edb.356 - gsmtp (in
20+
reply to end of DATA command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host smtpz4.laposte.net[106.29.142.66] said: 550 5.7.1
14+
Service refuse. Veuillez essayer plus tard. service refused, please try
15+
later. LPN007_510 (in reply to end of DATA command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host aspmx.l.google.com[124.205.72.62] said:
14+
550-5.7.26 Unauthenticated email from acme.com is not accepted due to
15+
domain's 550-5.7.26 DMARC policy. Please contact the administrator of
16+
acme.com domain 550-5.7.26 if this was a legitimate mail. Please visit
17+
550-5.7.26 https://support.google.com/mail/answer/2451690 to learn about
18+
the 550 5.7.26 DMARC initiative.
19+
v10-20020a170906488a11b0098d8390816asi945962ejq.756 - gsmtp (in reply to
20+
end of DATA command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host mx.zoho.eu[158.203.221.166] said: 554 5.2.3
14+
MailPolicy violation Error delivering to mailboxes (in reply to end of DATA
15+
command)

test/fixtures/554_5_4_0_hops.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
This is the mail system at host burns.eiro.biz.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
14+
balancer_haproxy.email.locaweb.com.br[1.13.102.292] said: 554 5.4.0 Error:
15+
too many hops (in reply to end of DATA command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
This is the mail system at host out41.mail.ovh.net.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host mxplan3.mail.ovh.net[49.32.197.262]
14+
said: 554 5.7.105 SenderFilterAgent; Sender denied as sender's email
15+
address is on SenderFilterConfig list (in reply to end of DATA command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host vero.in.mest.micro.com[81.280.22.8]
14+
said: 554 5.7.1 <[email protected]>: Recipient address rejected:
15+
BLOCK-SEND-ER. (in reply to RCPT TO command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host mx01.mail.icloud.com[71.75.155.43] said: 554
14+
5.7.1 [CS01] Message rejected due to local policy. Please visit
15+
https://support.apple.com/en-us/HT204137 (in reply to end of DATA command)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This is the mail system at host mailer.acme.email.
2+
3+
I'm sorry to have to inform you that your message could not
4+
be delivered to one or more recipients. It's attached below.
5+
6+
For further assistance, please send mail to postmaster.
7+
8+
If you do so, please include this problem report. You can
9+
delete your own text from the attached returned message.
10+
11+
The mail system
12+
13+
<[email protected]>: host mail2.etecsa.net[118.252.213.4] said: 554 5.7.1
14+
Service unavailable; Client host [39.177.48.171] blocked using
15+
0spam.fusionzero.com; Received: from mailer-2w.outbound.crisp.email
16+
([39.177.48.171]) Fri, 22 Sep 2023 01:01:01 +0000 Subject: Backlinking is
17+
not that crazy anymore (in reply to RCPT TO command)

0 commit comments

Comments
 (0)