diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-05-02 09:32:29 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-05-02 09:32:29 +0100 |
commit | 771b0f839458408a38b78e790fdd610251cec815 (patch) | |
tree | af3802e34b8bd0cef684a34e886141381f387c29 /script/handle-mail-replies | |
parent | 481e5d6c9d82cfc0cace474674b01376bc514417 (diff) | |
parent | c402c9aa3f96300eb1165364e6a0f1a50642297f (diff) |
Merge branch 'develop' of github.com:sebbacon/alaveteli into develop
Diffstat (limited to 'script/handle-mail-replies')
-rwxr-xr-x | script/handle-mail-replies | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/script/handle-mail-replies b/script/handle-mail-replies index cc7595bed..7590f5848 100755 --- a/script/handle-mail-replies +++ b/script/handle-mail-replies @@ -43,9 +43,22 @@ def main(in_test_mode) return 1 end - if is_oof? message - # Discard out-of-office messages - return 2 + # If we are still here, there are no permanent failures, + # so if the message is a multipart/report then it must be + # reporting a temporary failure. In this case we discard it + if message.content_type == "multipart/report" + return 1 + end + + # Another style of temporary failure message + subject = message.header_string("Subject") + if message.content_type == "multipart/mixed" && subject == "Delivery Status Notification (Delay)" + return 1 + end + + # Discard out-of-office messages + if is_oof?(message) + return 2 # Use a different return code, to distinguish OOFs from bounces end # Otherwise forward the message on @@ -94,6 +107,15 @@ def permanently_failed_addresses(message) end end + subject = message.header_string("Subject") + # Then look for the style we’ve seen in WebShield bounces + # (These do not have a return path of <> in the cases I have seen.) + if subject == "Returned Mail: Error During Delivery" + if message.body =~ /^\s*---- Failed Recipients ----\s*((?:<[^>]+>\n)+)/ + return $1.scan(/<([^>]+)>/).flatten + end + end + return [] end |