[imapfilter-devel] Imapfilter and Pipe commands
Lefteris Chatzibarbas
lefcha at hellug.gr
Fri Apr 2 18:07:36 EEST 2004
On Thu, Apr 01, 2004 at 10:37:37PM +0200, Cedric Pradalier wrote:
> Hi all,
>
> I just started to use imapfilter after using offlineimap. And this seems to
> be exactly the good tool for what I want to do. I first explain my setup
> and I'll come back on pipes later on
>
> First my setup. I have a always up computer at work with a very big
> connection and a laptop at home with a standard DSL connection and
> sometimes a 56k modem... As anybody I receive spams and I wanted not only
> to indentify them, but also to move them apart, in order to avoid
> downloading them while I'm using a slow connection. To this end, I set up
> imapfilter on my work machine (in a cron job since I was not totally
> convinced by the daemon mode...). Some of my spams are detected by a
> whole site spamassasin, and flagged with a [_SPAM_] in the subject. So no
> problem to move them.
>
> To identify other spams, I use spamprobe (a quite efficient bayesian
> filter) and also clamav to check for viruses. So I had to implement the
> external command, in a very similar way (that's coincidence) to what has
> been proposed on this list :
>
> filter spam2 and
> unseen
> external all "isspam.sh"
> action move Spam subject,from
>
> I choose to use only one external command (last one in the filter) which
> can select header,body or all. And if I have complex things to do, I do
> it in the shell script. This seems reasonable since this is not imapfilter
> goals to manage all the complexity I can imagine. isspam.sh looks like
> this :
>
> #!/bin/sh
> TEMP=`mktemp /tmp/$USER.XXXXXX`
> cat > $TEMP
> if spamprobe -d train $TEMP 2>&1 | grep SPAM >
> then
> rm -f $TEMP
> exit 0;
> fi
>
> if ! clamscan --mbox --stdout --disable-summary -i $TEMP
> then
> rm -f $TEMP
> exit 0
> fi
> rm -f $TEMP
> exit 1
>
> Also, in order to correct misclassification in spamprobe, I have to be
> able to make it read misclassified emails. So to make short, I added a
> pipe action, which permits to pipe selected messages to an external
> program, without taking care of its exit status :
>
> filter learnspam
> not deleted
> action pipe "learn.sh spam" subject
>
>
> So this is implemented and currently running. I can extract a patch (w.r.t
> 0.9.6) if someone is interested in testing it. I've browsed the archive
> and not found explicit implementation of this, so I propose mine.
>
> I hope you will not consider this long email a pollution...
I am currently working on a rewrite of the configuration file of IMAPFilter
(actually I just finished the coding and I'm doing testing/debugging).
The above functionality has been implemented, along with things like deletion
of duplicates, use of regular expressions everywhere in the configuration file,
piping of message header/body or specific headers to external programs
(antispam/bayesian/whatever), on the fly editing of messages, <you name it>.
That which stays the same is the basic philosophy: you declare some accounts
(server, username, password) and some filters. You apply these filters to IMAP
mailboxes and get the results (or you could now actually skip this part and
download the messages and do the filtering locally). Then you can delete,
display/list, flag, copy/move, fetch messages (or parts of them) and process
them endlessly, before uploading them back to the server or saving them to the
filesystem or whatever. Anything that involves processing of messages that
reside on IMAP mail servers.
I believe a beta version will be out soon (after I will return from my
vacation) and then some release candidates, before the final release.
More information about the Imapfilter-devel
mailing list