-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e9b0a0
commit f40c0cf
Showing
10 changed files
with
224 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,12 +110,13 @@ var REGEXES = { | |
|
||
recipient : [ | ||
/the following addresses had permanent fatal errors (?:.*?)\s\<(.+?)\>/i, | ||
/there was a temporary problem delivering your message to (.+?). Gmail will retry/i, | ||
/the following message to \<(.+?)\> was undeliverable/i, | ||
/to the following addresses:\s*(.+)/i, | ||
/^\<(.+?)\>:/m, | ||
/^(.+?)\s?(?:\s\(.*?\))?\n?\s*[\[|<]mailto\:(.+?)[\]|>]/mi, // "[email protected]<mailto:[email protected]>" or "[email protected][mailto:[email protected]]" or "[email protected] ([email protected])<mailto:[email protected]>" | ||
/^your message wasn't delivered to (.+?)\s/mi, // "Your message wasn't delivered to [email protected]" | ||
/^your message to (.+?) couldn\'t/mi, // "Your message to [email protected] couldn't" | ||
/^(.+?)\s?(?:\s\(.*?\))?\n?\s*[\[|<]mailto\:(.+?)[\]|>]/mi, // "[email protected]<mailto:[email protected]>" or "[email protected][mailto:[email protected]]" or "[email protected] ([email protected])<mailto:[email protected]>" | ||
/^\<(.+?)\>:/m, | ||
/\<(.+?)\> \(expanded from \<.+?\>\)\:/, // "<[email protected]> (expanded from <[email protected]>): " | ||
/\<(.+?)\>:/ // "<[email protected]>:" | ||
], | ||
|
@@ -147,6 +148,10 @@ var REGEXES = { | |
/(out of storage|(?:mailbox (?:is )?full)|(?:user (?:is )?over quota))/i // "user is over quota" (iCloud) | ||
], | ||
|
||
enhanced_types_reputation : [ | ||
/(rate limited due to IP reputation)/i | ||
], | ||
|
||
error_code : [ | ||
/(\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" | ||
/(\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 { | |
_permanent = true; | ||
} | ||
|
||
// Make sure the bounce is actually permanent | ||
if (_permanent === true) { | ||
var _match = this.__regexes.temporary_safe.match(str); | ||
|
||
if (_match && _match.length > 1) { | ||
_temporary = true; | ||
_permanent = false; | ||
} | ||
} | ||
|
||
if (_code.basic) { | ||
_type = ERROR_CODES_TYPES[_code.basic] || null | ||
} | ||
} | ||
|
||
// In cases where the bounce is detected as permanent, or the \ | ||
// temporary / permanent status is still unclear, run additional detection | ||
if (_permanent === true || (_temporary === false && _permanent === false)) { | ||
var _match = this.__regexes.temporary_safe.match(str); | ||
|
||
if (_match && _match.length > 1) { | ||
_temporary = true; | ||
_permanent = false; | ||
} | ||
} | ||
|
||
// No label detected? Probably because there's no error code | ||
if (!_label) { | ||
// Attempt a lax check | ||
|
@@ -409,6 +415,12 @@ class Parser { | |
_type = "mailbox_full"; | ||
} | ||
|
||
_match = loopRegexes(this.__regexes.enhanced_types_reputation, str); | ||
|
||
if (!_type && _match && _match.length > 1) { | ||
_type = "reputation"; | ||
} | ||
|
||
// Detect enhanced-type from enhanced error code | ||
// Notice: this is done as a last resort, as sometimes enhanced code \ | ||
// doesn't clearly convey the actual error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
This is the mail system at host mailer.acme.email. | ||
|
||
I'm sorry to have to inform you that your message could not | ||
be delivered to one or more recipients. It's attached below. | ||
|
||
For further assistance, please send mail to postmaster. | ||
|
||
If you do so, please include this problem report. You can | ||
delete your own text from the attached returned message. | ||
|
||
The mail system | ||
|
||
<[email protected]>: host | ||
outlook-com.olc.protection.outlook.com[140.74.55.33] said: 451 4.7.650 The | ||
mail server [39.177.48.16] has been temporarily rate limited due to IP | ||
reputation. For e-mail delivery information, see | ||
https://postmaster.live.com (S843) (in reply to RCPT TO command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Delivery has failed to these recipients or groups: | ||
|
||
[email protected]<mailto:[email protected]> | ||
Your message couldn't be delivered to the recipient because you don't have permission to send to it. | ||
|
||
Ask the recipient's email admin to add you to the accept list for the recipient. | ||
|
||
For more information, see DSN 5.7.129 Errors in Exchange Online and Office 365<https://go.microsoft.com/fwlink/?LinkId=389365>. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Diagnostic information for administrators: | ||
|
||
Generating server: EV2MR07MI7830.eurprd06.prod.outlook.com | ||
|
||
[email protected] | ||
Remote server returned '550 5.7.129 RESOLVER.RST.RestrictedToRecipientsPermission; not authorized to send to recipient because the sender isn't on the recipient's list of senders to accept mail from' | ||
|
||
Original message headers: | ||
|
||
REDACTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
** Delivery incomplete ** | ||
|
||
There was a temporary problem delivering your message to [email protected]. Gmail will retry for 47 more hours. You'll be notified if the delivery fails permanently. | ||
|
||
Learn more here: https://support.google.com/mail/answer/188131 | ||
|
||
The response from the remote server was: | ||
550 5.7.1 [2500:1109:110::11 91] Gmail has detected that this message is likely suspicious due to the very low reputation of the sending domain. To best protect our users from spam, the message has been blocked. Please visit https://support.google.com/mail/answer/188131 for more information. t64-20020a1fc343000000b0049d0aa186d9si449748vkf.30 - gsmtp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"bounce": true, | ||
"email": { | ||
"body": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system\n\n<[email protected]>: host outlook-com.olc.protection.outlook.com[140.74.55.33] said: 451 4.7.650 The mail server [39.177.48.16] has been temporarily rate limited due to IP reputation. For e-mail delivery information, see https://postmaster.live.com (S843) (in reply to RCPT TO command)", | ||
"intro": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system", | ||
"error": "<[email protected]>: host outlook-com.olc.protection.outlook.com[140.74.55.33] said: 451 4.7.650 The mail server [39.177.48.16] has been temporarily rate limited due to IP reputation. For e-mail delivery information, see https://postmaster.live.com (S843) (in reply to RCPT TO command)" | ||
}, | ||
"data": { | ||
"error": { | ||
"code": { | ||
"basic": "451", | ||
"enhanced": "4.7.650" | ||
}, | ||
"label": "The mail server [39.177.48.16] has been temporarily rate limited due to IP reputation. For e-mail delivery information, see https://postmaster.live.com (S843)", | ||
"type": "action_aborted_local_error", | ||
"temporary": true, | ||
"permanent": false, | ||
"data": { | ||
"type": "reputation", | ||
"blocked": false, | ||
"spam": false | ||
} | ||
}, | ||
"recipient": "[email protected]", | ||
"server": { | ||
"hostname": "outlook-com.olc.protection.outlook.com", | ||
"ip": "140.74.55.33", | ||
"port": null | ||
}, | ||
"command": "RCPT TO" | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
test/fixtures/expected/550_5_7_129_restricted_permissions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"bounce": true, | ||
"email": { | ||
"body": "Delivery has failed to these recipients or groups:\n\n[email protected]<mailto:[email protected]>\nYour message couldn't be delivered to the recipient because you don't have permission to send to it.\n\nAsk the recipient's email admin to add you to the accept list for the recipient.\n\nFor more information, see DSN 5.7.129 Errors in Exchange Online and Office 365<https://go.microsoft.com/fwlink/?LinkId=389365>.\n\n\n\n\n\n\n\n\n\nDiagnostic information for administrators:\n\nGenerating server: EV2MR07MI7830.eurprd06.prod.outlook.com\n\n[email protected]\nRemote server returned '550 5.7.129 RESOLVER.RST.RestrictedToRecipientsPermission; not authorized to send to recipient because the sender isn't on the recipient's list of senders to accept mail from'\n\nOriginal message headers:\n\nREDACTED", | ||
"intro": null, | ||
"error": null | ||
}, | ||
"data": { | ||
"error": { | ||
"code": { | ||
"basic": "550", | ||
"enhanced": "5.7.129" | ||
}, | ||
"label": "RESOLVER.RST.RestrictedToRecipientsPermission; not authorized to send to recipient because the sender isn't on the recipient's list of senders to accept mail from", | ||
"type": "action_not_taken", | ||
"temporary": false, | ||
"permanent": true, | ||
"data": { | ||
"type": null, | ||
"blocked": false, | ||
"spam": false | ||
} | ||
}, | ||
"recipient": "[email protected]", | ||
"server": { | ||
"hostname": "EV2MR07MI7830.eurprd06.prod.outlook.com", | ||
"ip": null, | ||
"port": null | ||
}, | ||
"command": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"bounce": true, | ||
"email": { | ||
"body": "** Delivery incomplete **\n\nThere was a temporary problem delivering your message to [email protected]. Gmail will retry for 47 more hours. You'll be notified if the delivery fails permanently.\n\nLearn more here: https://support.google.com/mail/answer/188131\n\nThe response from the remote server was:\n550 5.7.1 [2500:1109:110::11 91] Gmail has detected that this message is likely suspicious due to the very low reputation of the sending domain. To best protect our users from spam, the message has been blocked. Please visit https://support.google.com/mail/answer/188131 for more information. t64-20020a1fc343000000b0049d0aa186d9si449748vkf.30 - gsmtp", | ||
"intro": null, | ||
"error": null | ||
}, | ||
"data": { | ||
"error": { | ||
"code": { | ||
"basic": "550", | ||
"enhanced": "5.7.1" | ||
}, | ||
"label": "[2500:1109:110::11 91] Gmail has detected that this message is likely suspicious due to the very low reputation of the sending domain. To best protect our users from spam, the message has been blocked. Please visit https://support.google.com/mail/answer/188131 for more information. t64-20020a1fc343000000b0049d0aa186d9si449748vkf.30 - gsmtp", | ||
"type": "action_not_taken", | ||
"temporary": true, | ||
"permanent": false, | ||
"data": { | ||
"type": "spam_content", | ||
"blocked": true, | ||
"spam": true | ||
} | ||
}, | ||
"recipient": "[email protected]", | ||
"server": { | ||
"hostname": null, | ||
"ip": null, | ||
"port": null | ||
}, | ||
"command": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"bounce": true, | ||
"email": { | ||
"body": "** Delivery incomplete **\n\nThere was a temporary problem delivering your message to [email protected]. Gmail will retry for 46 more hours. You'll be notified if the delivery fails permanently.", | ||
"intro": null, | ||
"error": null | ||
}, | ||
"data": { | ||
"error": { | ||
"code": { | ||
"basic": null, | ||
"enhanced": null | ||
}, | ||
"label": null, | ||
"type": null, | ||
"temporary": true, | ||
"permanent": false, | ||
"data": { | ||
"type": null, | ||
"blocked": false, | ||
"spam": false | ||
} | ||
}, | ||
"recipient": "[email protected]", | ||
"server": { | ||
"hostname": null, | ||
"ip": null, | ||
"port": null | ||
}, | ||
"command": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
** Delivery incomplete ** | ||
|
||
There was a temporary problem delivering your message to [email protected]. Gmail will retry for 46 more hours. You'll be notified if the delivery fails permanently. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters