Am Samstag, 13. Oktober 2007 03:05:05 schrieb Gordon Messmer:
> Daniel wrote:
> > I'm just looking for a "Hello World" like piece of code. I would prefer a
> > script language (eg bash, python, php :) ). Rejecting mail if title
> > is "reject me" sounds fine to me for an "Hello World" like filter...
>
> Python I can do. ;)
>
> I've got some documentation on writing filters in python here:
> http://phantom.dragonsdawn.net/~gordon/courier-pythonfilter/latest/README.h
>acking
>
> You started this thread asking about message recipients.  The best
> example I've got of a working filter that examines the recipient list is
> here:
> http://phantom.dragonsdawn.net/~gordon/courier-pythonfilter/latest/filters/
>privateaddr.py
>
> It's a little more complex than "hello world", but not much.  I'm happy
> to answer questions about python filter development.

Hi,
that is what I'm looking for.

But if I try to use the xfilter module, I got following exception on submit:

Uncaught exception in "logfilter" doFilter function: 
courier.xfilter.SubmitError:'Error reading response, got ""'
 File "/etc/courier/filters/active/pythonfilter", line 181, in processMessage
   replyCode = i_filter[1](bodyFile, controlFileList)
 File "/usr/lib/python2.4/site-packages/pythonfilter/logfilter.py", line 29, 
in doFilter
 mfilter.submit()
 File "/usr/lib/python2.4/site-packages/courier/xfilter.py", line 193, in 
submit
 _submit_recv(sInput, sOutput)
 File "/usr/lib/python2.4/site-packages/courier/xfilter.py", line 149, in 
_submit_recv
 recvData = _submit_read_response(sOutput)
 File "/usr/lib/python2.4/site-packages/courier/xfilter.py", line 134, in 
_submit_read_response
 raise SubmitError('Error reading response, got "%s"' % response)

This is reproducable by me with the following code (which is mostly 
copy&pasted from your filters ;-) ):

#!/usr/bin/env python

import sys
import courier.control
import courier.xfilter

sys.stderr.write('Initialized the "add_orig_receipient" python filter\n')

def doFilter(bodyFile, controlFileList):
        for addr in courier.control.getRecipientsData(controlFileList):
                if addr[1]:
                        if(addr[1].startswith('rfc822;')):
                                rcpt = addr[1][7:]
                        else:
                                rcpt = addr[1]
                else:
                        rcpt = addr[0]

        sys.stderr.write('Receipient: %s\n' % rcpt)

        try:
                mfilter = courier.xfilter.XFilter('testxfilter', bodyFile,
                controlFileList)
        except courier.xfilter.LoopError, e:
                # LoopError indicates that we've already filtered this 
message.
                return ''

        mmsg = mfilter.getMessage()
        mmsg['X-Orig-Receipient'] = rcpt
        mfilter.submit()

        return ''


Did you need some more informations?

regards
Daniel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to