

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
4 messages in net.sourceforge.lists.courier-usersRe: [courier-users] Integrating Spama...| From | Sent On | Attachments |
|---|---|---|
| Jérôme Blion | May 13, 2007 7:38 pm | |
| Jérôme Blion | May 13, 2007 7:50 pm | |
| Gordon Messmer | May 14, 2007 9:34 am | |
| Jérôme Blion | May 14, 2007 10:00 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread 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 pythonfilter | Actions... |
|---|---|---|
| From: | Jérôme Blion (jero...@free.fr) | |
| Date: | May 14, 2007 10:00:19 am | |
| List: | net.sourceforge.lists.courier-users | |
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 <rob...@penz.name>
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 <jer...@hebergement-pro.org> # # 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 <jer...@hebergement-pro.org> # # 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], "")







