This post originated from an RSS feed registered with Python Buzz
by Ng Pheng Siong.
Original Post: XMail Spambayes
Feed Title: (render-blog Ng Pheng Siong)
Feed URL: http://sandbox.rulemaker.net/ngps/rdf10_xml
Feed Description: Just another this here thing blog.
Who are these people who send me mail: ulycufueohvx@proxad.net,
dndpfk@anet.net, ltw707oga@chollian.net?
XMail offers a mechanism to run message filters during an SMTP
session. There are several XMail filters available that invoke
SpamAssassin, written in Perl, and one that does SPF, written in
Python.
It is quite easy add to an SMTP filter to XMail. Here's my Spambayes
filter which took just several minutes to write, and I've never seen
Spambayes before this. It seems to work, too.
#!/usr/bin/env python
import sys
from spambayes import hammie
hammie_db = '/usr/local/pkg/xmail/hammie.db'
REJECT = 3
def main(argv):
if len(argv) != 2:
sys.exit(0)
filter = hammie.open(hammie_db)
spam_prob = filter.score(open(argv[1]))
if spam_prob >= 0.5:
sys.exit(REJECT)
if __name__ == '__main__':
main(sys.argv)
hammie.db is the output of sb_mboxtrain.py.
If the filter finishes with exit code 3, XMail drops the message
without spooling it to the user mailbox; any other exit code causes
XMail to accept the message. A filter may modify the message data,
e.g., do the regular Spambayes thing of adding an X-Spam-BlahBlah
header.
To turn the filter on, edit the file filters.post-data.tab thusly: