diff options
-rwxr-xr-x | split-mailman-mails-and-discard-and-save | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/split-mailman-mails-and-discard-and-save b/split-mailman-mails-and-discard-and-save index aec0bc8..d5d1ffa 100755 --- a/split-mailman-mails-and-discard-and-save +++ b/split-mailman-mails-and-discard-and-save @@ -2,10 +2,19 @@ require 'rmail' - -MAILIN="mail-in" -SPAM="spam-learn" -OUTBOX="outbox" +if ARGV[0] == "spam" + MAILIN="spam-in" + MAILLEARN="spam-learn" + OUTBOX="outbox" + SEND_DISCARD_MAIL = true +elsif ARGV[0] == "ham" + MAILIN="ham-in" + MAILLEARN="ham-learn" + OUTBOX="outbox" + SEND_DISCARD_MAIL = false +else + stderr.puts "Usage: $0 ham|spam" +end DOMAIN='lists.oftc.net' FROM="listmoderators@lists.oftc.net" @@ -68,17 +77,20 @@ def process_mail(filename) throw "Could not find cookie in discard_part" unless matchdata and matchdata[1] cookie = matchdata[1] - store_in_maildir(SPAM, held_part) - 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.body = '' - store_in_maildir(OUTBOX, mail_request) + store_in_maildir(MAILLEARN, held_part) + + if SEND_DISCARD_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.body = '' + store_in_maildir(OUTBOX, mail_request) + end end check_maildir MAILIN -check_maildir SPAM +check_maildir MAILLEARN check_maildir OUTBOX Dir[MAILIN+"/new/*"].each do |filename| |