Gordon Messmer <[EMAIL PROTECTED]> writes:
> [ ... ]
> If there is a variable named "order" in the module, it will be used to
> determine the order in which filters run. "whitelist.py" has order=0 to
> make sure it runs first. I suggest setting the value in your filter to
> 1.
>
> [ ... ]
>
> From the README file:
>
> This function will be called to filter each incoming message. This
> function should return either the empty string ('') to indicate
> success, and that other filters may run, or it should return an SMTP
> style response. The response will be passed on directly to Courier,
> and in the case of failure responses, passed on to the client sending
> the message. A filter may return an SMTP success code ('200 Ok') to
> indicate that the message is OK, and that no further filters should
> run.
I thought that this message of mine didn't go out due to a mail client
error that occurred during sending. However, I guess you got it anyway.
As soon as I sent it, I found and read the README documention, which I
had initially overlooked.
Also, I've been able to answer my other question, which you should have
already received: I figured out that the `message_body' argument to the
dofilter method is the name of the _file_ that the message body resides
in, not the message body data itself.
>From that, I wrote the following filter which does this authorization
test. I just set `order' to something greater than 1 in the spf filter,
and it all seems to work.
(Note: in `pythonfilter' and all the supplied filters, it might
be good to rename the first argument of dofilter to
"message_body_file" or perhaps "message_data_file".
What do you think of this idea for the next
courier-pythonfilter release?)
import re
import sys
import string
import courier.control
import courier.config
# Accepts all incoming messages that have been submitted via a
# successful AUTH dialog.
# Run before any other filter.
order = 1
# Record in the system log that this filter was initialized.
sys.stderr.write( 'Initialized the AUTH python filter\n' )
authpat = re.compile(r'\bAUTH:\s+LOGIN\b', re.I)
def dofilter( message_body, message_ctrl_files ):
lines = open(message_body,'r').readlines()
lines = map(string.strip, lines)
for line in lines:
match = authpat.search(line)
if match:
sys.stderr.write('Login authorization succeeded: message accepted\n')
return '200 Ok'
return ''
--
Lloyd Zusman
[EMAIL PROTECTED]
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users