From 89a640353f641c8b451bc22fcf4a68bd4dd1e886 Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Mon, 30 Apr 2012 11:02:34 +0100 Subject: Recognise another variety of bounce message --- script/handle-mail-replies | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'script/handle-mail-replies') diff --git a/script/handle-mail-replies b/script/handle-mail-replies index cc7595bed..aba4ac29b 100755 --- a/script/handle-mail-replies +++ b/script/handle-mail-replies @@ -43,9 +43,16 @@ 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 + + # 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 +101,14 @@ def permanently_failed_addresses(message) end end + # 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 message.header_string("Subject") == "Returned Mail: Error During Delivery" + if message.body =~ /^\s*---- Failed Recipients ----\s*((?:<[^>]+>\n)+)/ + return $1.scan(/<([^>]+)>/).flatten + end + end + return [] end -- cgit v1.2.3 From c402c9aa3f96300eb1165364e6a0f1a50642297f Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Tue, 1 May 2012 18:19:05 +0100 Subject: Handle yet another style of bounce --- script/handle-mail-replies | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'script/handle-mail-replies') diff --git a/script/handle-mail-replies b/script/handle-mail-replies index aba4ac29b..7590f5848 100755 --- a/script/handle-mail-replies +++ b/script/handle-mail-replies @@ -50,6 +50,12 @@ def main(in_test_mode) 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 @@ -101,9 +107,10 @@ 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 message.header_string("Subject") == "Returned Mail: Error During Delivery" + if subject == "Returned Mail: Error During Delivery" if message.body =~ /^\s*---- Failed Recipients ----\s*((?:<[^>]+>\n)+)/ return $1.scan(/<([^>]+)>/).flatten end -- cgit v1.2.3