aboutsummaryrefslogtreecommitdiffstats
path: root/script/handle-mail-replies
diff options
context:
space:
mode:
authorRobin Houston <robin.houston@gmail.com>2012-04-30 11:02:34 +0100
committerRobin Houston <robin.houston@gmail.com>2012-04-30 11:02:34 +0100
commit89a640353f641c8b451bc22fcf4a68bd4dd1e886 (patch)
tree7d280b4e98ee9f997c9c2bb5421fe3c7664287fd /script/handle-mail-replies
parentcbe6736db771dc51b28b16bd7780e2fea4c4d0f4 (diff)
Recognise another variety of bounce message
Diffstat (limited to 'script/handle-mail-replies')
-rwxr-xr-xscript/handle-mail-replies21
1 files changed, 18 insertions, 3 deletions
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