Hello,
I found no modules to integrate spamassassin into pythonfilter.
I found no python "modules" that I could have imported.
So, the way I use to scan mails are the less worst I found... using spamc...
For people who want to use it, be careful: mails are refused, not moved
in a "junk" folder. So, take care about the score ;)
What do you think about this piece of code?
Now, pythonfilter is filtering spams and viruses... All that I need :)
HTH :)
#!/usr/bin/python
# spamassassin -- Courier filter which scans messages with spamassassin
# Copyright (C) 2004 Robert Penz <[EMAIL PROTECTED]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys
import commands
# Record in the system log that this filter was initialized.
sys.stderr.write('Initialized the "spamassasinfilter" python filter\n')
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
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], "")
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users