4 messages in net.sourceforge.lists.courier-usersRe: [courier-users] Integrating Spama...
FromSent OnAttachments
Jérôme BlionMay 13, 2007 7:38 pm 
Jérôme BlionMay 13, 2007 7:50 pm 
Gordon MessmerMay 14, 2007 9:34 am 
Jérôme BlionMay 14, 2007 10:00 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [courier-users] Integrating Spamassassin in pythonfilterActions...
From:Gordon Messmer (yiny@eburg.com)
Date:May 14, 2007 9:34:44 am
List:net.sourceforge.lists.courier-users

Jérôme Blion wrote:

#!/usr/bin/python # spamassassin -- Courier filter which scans messages with spamassassin # Copyright (C) 2004 Robert Penz <rob@penz.name>

You should use your own copyright string here.

...

def doFilter(bodyFile, controlFileList): # check for viruses try: cmd = '/usr/bin/spamc -c < ' + bodyFile (status,output) = commands.getstatusoutput(cmd)

except Exception, e: return "554 " + str(e)

if status != 0: return '554 Mail rejected - spam detected: '+ output return '200 Spamassassin score: '+ output

You probably don't want to return a 200 code. Your spamassassin module will stop other filters from running. See the "README.hacking" file.

if __name__ == '__main__': # we only work with 2 parameter if len(sys.argv) != 2: print "Usage: spamassassin.py <message_body_file> <controlFileList>" sys.exit(0) print doFilter(sys.argv[1], "")

Your "usage" text tells users to give two arguments, but the function will not run the filter unless only one is given. You should fix that, too.