It’s just data

Filtering the ASF Secretary Inbox

It was only a matter of time, but apparently a few spammers have discovered the Apache Secretary mailing list address.  It’s time to integrate SpamAssassin into the Secretary Workflow:

import email
from subprocess import Popen, PIPE
from threading import Thread

def analyze(msg):
  spamc = Popen('spamc', shell=True, stdin=PIPE, stdout=PIPE)
  class passthru(Thread):
    def __init__(self, stdin, msg):
      Thread.__init__(self)
      self.msg = msg
      self.stdin = stdin
    def run(self):
      email.generator.Generator(self.stdin).flatten(self.msg)
      self.stdin.close()
  thread = passthru(spamc.stdin, msg)
  thread.start()
  msg = email.message_from_file(spamc.stdout)
  setattr(msg, 'spam', str(msg['X-Spam-Status']).startswith('Yes'))
  thread.join()
  spamc.stdout.close()
  spamc.wait()
  return msg

Add your comment