aboutsummaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rwxr-xr-xscript/check-recent-requests-sent2
-rwxr-xr-xscript/handle-mail-replies.rb28
-rwxr-xr-xscript/load-mail-server-logs (renamed from script/load-exim-logs)10
3 files changed, 23 insertions, 17 deletions
diff --git a/script/check-recent-requests-sent b/script/check-recent-requests-sent
index 588c6b73a..7840dba4a 100755
--- a/script/check-recent-requests-sent
+++ b/script/check-recent-requests-sent
@@ -2,7 +2,7 @@
cd "`dirname "$0"`"
-bundle exec ./runner 'EximLog.check_recent_requests_have_been_sent'
+bundle exec ./runner 'MailServerLog.check_recent_requests_have_been_sent'
diff --git a/script/handle-mail-replies.rb b/script/handle-mail-replies.rb
index b227864b5..f4ffb61f8 100755
--- a/script/handle-mail-replies.rb
+++ b/script/handle-mail-replies.rb
@@ -15,6 +15,8 @@
$alaveteli_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
$:.push(File.join($alaveteli_dir, "commonlib", "rblib"))
load "config.rb"
+$:.push(File.join($alaveteli_dir, "lib"))
+require "configuration"
MySociety::Config.set_file(File.join($alaveteli_dir, 'config', 'general'), true)
MySociety::Config.load_default
@@ -30,7 +32,7 @@ def main(in_test_mode)
forward_on(raw_message) unless in_test_mode
return 0
end
-
+
pfas = permanently_failed_addresses(message)
if !pfas.empty?
if in_test_mode
@@ -42,25 +44,25 @@ def main(in_test_mode)
end
return 1
end
-
+
# 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
forward_on(raw_message) unless in_test_mode
return 0
@@ -70,7 +72,7 @@ end
def permanently_failed_addresses(message)
if message.header_string("Return-Path") == "<>"
# Some sort of auto-response
-
+
# Check for Exim’s X-Failed-Recipients header
failed_recipients = message.header_string("X-Failed-Recipients")
if !failed_recipients.nil?
@@ -81,7 +83,7 @@ def permanently_failed_addresses(message)
return failed_recipients.split(/,\s*/)
end
end
-
+
# Next, look for multipart/report
if message.content_type == "multipart/report"
permanently_failed_recipients = []
@@ -89,7 +91,7 @@ def permanently_failed_addresses(message)
if part.content_type == "message/delivery-status"
sections = part.body.split(/\r?\n\r?\n/)
# The first section is a generic header; subsequent sections
- # represent a particular recipient. Since we
+ # represent a particular recipient. Since we
sections[1..-1].each do |section|
if section !~ /^Status: (\d)/ || $1 != '5'
# Either we couldn’t find the Status field, or it was a transient failure
@@ -106,7 +108,7 @@ def permanently_failed_addresses(message)
end
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.)
@@ -121,11 +123,11 @@ end
def is_oof?(message)
# Check for out-of-office
-
+
if message.header_string("X-POST-MessageClass") == "9; Autoresponder"
return true
end
-
+
subject = message.header_string("Subject").downcase
if message.header_string("Return-Path") == "<>"
if subject.start_with? "out of office: "
@@ -135,13 +137,13 @@ def is_oof?(message)
return true
end
end
-
+
if message.header_string("Auto-Submitted") == "auto-generated"
if subject =~ /out of( the)? office/
return true
end
end
-
+
if subject.start_with? "out of office autoreply:"
return true
end
diff --git a/script/load-exim-logs b/script/load-mail-server-logs
index 00b6b9825..9ff7a1401 100755
--- a/script/load-exim-logs
+++ b/script/load-mail-server-logs
@@ -2,6 +2,10 @@
LOC=`dirname "$0"`
+cd "$LOC"/..
+source commonlib/shlib/deployfns
+read_conf config/general
+
# Specific file if specified
if [ x$1 != x ]
then
@@ -10,14 +14,14 @@ then
*) f=$(pwd)/$1 ;;
esac
cd "$LOC"
- bundle exec ./runner 'EximLog.load_file("'$f'")'
+ bundle exec ./runner 'MailServerLog.load_file("'$f'")'
exit
fi
# Load in last three days worth of logs (if they've been modified)
cd "$LOC"
-LATEST=$( ls /var/log/exim4/exim-mainlog-* 2>/dev/null | sort | tail -3 )
+LATEST=$( ls $OPTION_MTA_LOG_PATH 2>/dev/null | sort | tail -3 )
for X in $LATEST
do
- bundle exec ./runner 'EximLog.load_file("'$X'")'
+ bundle exec ./runner 'MailServerLog.load_file("'$X'")'
done