Gordon Messmer a écrit :
Jérôme Blion wrote:
#!/usr/bin/python
# spamassassin -- Courier filter which scans messages with spamassassin
# Copyright (C) 2004 Robert Penz <[EMAIL PROTECTED]>
You should use your own copyright string here.
I should definitely not work at 4AM :)
...
You probably don't want to return a 200 code. Your spamassassin module
will stop other filters from running. See the "README.hacking" file.
Indeed, I read it too quickly...
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], "")
Indeed...the first argument of argv is the command name...
Thanks for your reply... :)
Here are the 2 updated scripts.
Feel free to include them if you want.
BR.
Jerome Blion.
#!/usr/bin/python
# clamav -- Courier filter which scans messages with ClamAV
# Copyright (C) 2007 Jerome Blion <[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 pyclamd
# Record in the system log that this filter was initialized.
sys.stderr.write('Initialized the "clamdfilter" python filter\n')
def doFilter(bodyFile, controlFileList):
# check for viruses
try:
pyclamd.init_unix_socket('/tmp/clamd')
avresult = pyclamd.contscan_file(bodyFile)
except Exception, e:
return "554 " + str(e)
if str(avresult) == 'None':
return ''
if avresult.has_key(bodyFile):
return "554 %s was detected. Abort!" % avresult[bodyFile]
if __name__ == '__main__':
# we only work with 1 parameter
if len(sys.argv) != 2:
print "Usage: clamd.py <message_body_file>"
sys.exit(0)
print doFilter(sys.argv[1], "")
#!/usr/bin/python
# spamassassin -- Courier filter which scans messages with spamassassin
# Copyright (C) 2007 Jerome Blion <[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 ''
if __name__ == '__main__':
# we only work with 1 parameter
if len(sys.argv) != 2:
print "Usage: spamassassin.py <message_body_file>"
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