[please cc me on responses, I'm not subscribed to the list]

Hi all,
Nice job on getting 2.0 out today, just upgraded to it. (Hope I didn't break
anything!)

I'm using spamassassin with qmail, so I wrote a short Python script to
translate SpamAssassin's -e codes to qmail-compatible codes. If a message is
spam, then it uses safecat to deliver it to the Spam folder, otherwise it
lets qmail proceed with normal delivery.

I also noticed that the HTML ads on YahooGroups were causing spamassassin to
create a bunch of false positives, so I delete those before passing the
message to spamassasin.

The file is attached below, I hope it's useful. I am of course interested in
better ways to do this.

All the best,

- [ "Aaron Swartz" ; <mailto:[EMAIL PROTECTED]> ; <http://www.aaronsw.com/> ]

#!/usr/bin/python2.2
"""
qmail-spamc - A wrapper to interface spamassassin with qmail.
$ echo "|qmail-spamc" >> $HOME/.qmail
$ echo "./Maildir/" >> $HOME/.qmail   # your normal mail spool
Spam gets placed in the spam directory while real mail is passed thru.
"""
REMOVEADS = 1
import sys, popen2

email = sys.stdin.read()

if REMOVEADS:
        import re
        x = re.compile(r"<!-- \|\*\*\|begin egp html banner\|\*\*\|
-->.*?<!-- \|\*\*\|end egp html banner\|\*\*\| -->", re.M|re.S)
        email = x.sub('', email)

s = popen2.Popen4('spamassassin -Pe')
s.tochild.write(email)
s.tochild.close()
mail = s.fromchild.read()
result = s.wait() >> 8

if result == 0: sys.exit(0)
else:
  s = popen2.Popen4('safecat $HOME/Maildir/.Spam/tmp/
$HOME/Maildir/.Spam/cur/')
  s.tochild.write(mail)
  s.tochild.close()
  s.wait() 
  sys.exit(99)


_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to