summaryrefslogtreecommitdiff
path: root/split-mailman-mails-and-discard-and-save
diff options
context:
space:
mode:
Diffstat (limited to 'split-mailman-mails-and-discard-and-save')
-rwxr-xr-xsplit-mailman-mails-and-discard-and-save27
1 files changed, 19 insertions, 8 deletions
diff --git a/split-mailman-mails-and-discard-and-save b/split-mailman-mails-and-discard-and-save
index 79711d9..9dc5b1a 100755
--- a/split-mailman-mails-and-discard-and-save
+++ b/split-mailman-mails-and-discard-and-save
@@ -1,6 +1,7 @@
#!/usr/bin/ruby
require 'rmail'
+require 'yaml'
if ARGV[0] == "spam"
MAILIN="mail/spam-in"
@@ -13,7 +14,7 @@ elsif ARGV[0] == "ham"
MAILLEARN="mail/ham-learn"
OUTBOX="mail/outbox"
SEND_CONFIRM_MAIL = true
- APPROVE_PASSWORD = File.open('mailman-site-password').readline.chomp
+ APPROVE_PASSWORD = YAML::load( File.open( 'mailman-passwords.yaml' ) )
else
STDERR.puts "Usage: #{$0} ham|spam"
exit 1
@@ -22,6 +23,7 @@ end
DOMAIN='lists.oftc.net'
FROM="listmod@blackhole.oftc.net"
HOSTNAME=`hostname`.chop
+ERRORSTO=FROM
class Counter
@@counter = 0
@@ -83,13 +85,22 @@ def process_mail(filename)
store_in_maildir(MAILLEARN, held_part)
if SEND_CONFIRM_MAIL
- mail_request = RMail::Message.new()
- mail_request.header['From'] = FROM
- mail_request.header['To'] = request_address
- mail_request.header['Subject'] = "Re: confirm #{cookie}"
- mail_request.header['Approved'] = APPROVE_PASSWORD if APPROVE_PASSWORD
- mail_request.body = ''
- store_in_maildir(OUTBOX, mail_request)
+ if APPROVE_PASSWORD and not APPROVE_PASSWORD[request_address] then
+ mail_error = RMail::Message.new()
+ mail_error.header['From'] = FROM
+ mail_error.header['To'] = ERRORSTO
+ mail_error.header['Subject'] = "approving #{cookie} failed"
+ mail_error.body = 'Sorry, this script does not have the admin/moderator password for #{request_address}.'
+ store_in_maildir(OUTBOX, mail_request)
+ else
+ mail_request = RMail::Message.new()
+ mail_request.header['From'] = FROM
+ mail_request.header['To'] = request_address
+ mail_request.header['Subject'] = "Re: confirm #{cookie}"
+ mail_request.header['Approved'] = APPROVE_PASSWORD if APPROVE_PASSWORD
+ mail_request.body = ''
+ store_in_maildir(OUTBOX, mail_request)
+ end
end
end