Hi,
Is the only way to send an email to an external filter to use the
xfilter command? The reason I ask is that I would like to be able to
send a message to a filter and get the external filter result back on
stdout or as its exitcode.
My particular challenge: I have a quick little python program that
extracts URLs from an email message, performs a URI rbl lookup on them,
and adds a header back to the email containing how many were listed
(hits) and how many weren't (misses). Maildrop uses a regex to pull the
header info out.
## Code snippet
xfilter "/home/vmail/URLscanner.py"
/^X-SURBL:.*Hits=([0-9]+), Misses=([0-9]+)/
HITS=$MATCH1
MISSES=$MATCH2
if ($HITS > 3 )
{
to "$DEFAULT/.URLscanner/"
}
####
There are two (at least) issues I have with this.
1) I would prefer not to change the email by adding a header, so it can
be used for training a spam filter later.
2) Why send the entire email back when I only need a single integer
reply? If maildrop would let me pipe a message to a filter without
requiring that the entire message be handed back, I could have the
filter print the hits to stdout and do this:
if (`/home/vmail/URLscanner.py` > 3)
{
to "$DEFAULT/.URLscanner/"
}
That seems much simpler and cleaner...
So. Why is there no facility in Maildrop to interface with external
programs where either their exitcode returns a useful, non-zero number
or where their stdout contains filter information but not the message
itself. Procmail has this, and I have found it very useful. Wouldn't it
be a logical addition to put this functionality into Maildrop?
Please consider giving us an option where a message is piped to an
external filter but where stdout is not expected to be the message but
rather a report on the filter results, and where the exitcode can be
non-zero and used for filtering decisions. Given the fact that a
Google search reveals several "wrappers" people have made for external
filters (for example,
http://www.hodgman.org/dick/linux/configure-dcc-for-maildrop.html for
DCC), I don't think I am the only one who would appreciate this.
Jeff