Newbie query: working on already delivered messages - batch mode?

Chris Wilkes cwilkes-bf at ladro.com
Fri Jun 10 02:11:57 CEST 2005


On Thu, Jun 09, 2005 at 04:49:39PM -0700, D Ruggiero wrote:
> So, Bogofilter's happily installed on my ancient RH 7.1 mail server (don't 
> ask) and is so much easier, more efficient, and accurate to the client-side 
> filter I had been using that it's laughable. So far, so good - thanks for 
> the great work.

What version of BerkeleyDB did you use?  I'm just wondering how you went
about upgrading that as it is usually a pain.

> However: due to my bizarro setup here, I'm only able to filter messages 
> after they're already delivered (ie, in my maildir as separate files, one 
> per message). Again, don't ask. :)  What I really want to do is simply have 
> Bogofilter look at each message and insert its X-Bogosity header "in-situ", 
> without otherwise changing the message or its filename. Right now I'm doing 
> this with a bash script:

That's probably not a good idea to do it to the exact same file name.
What happens when your bogofilter script runs and the message is popped
off the server at that moment?

> #!/bin/bash
> cd [my maildir]
> find . -type f -newer bogotime > /tmp/bogofiles
> touch bogotime
> 
> xargs -i -r bash -c "/bin/mv {} bogotmp; bogofilter -peI bogotmp -O {}" \; 
> < /tmp/bogofiles
> 
> rm -f bogotmp /tmp/bogofiles
> exit 0

If you have control to which folder these emails are sent to have them
go to a folder like
  ./Maildir/.unfiltered/
and then go through those and move them into the
  ./Maildir/new
directory using the "safecat" program:
  http://jeenyus.net/~budney/linux/software/safecat.html

> Two problems with this: first, it seems like an ugly kluge, and second, it 
> requires a file move and a separate invocation of bogofilter for every 
> message. Surely there must be a better way? Is there method to get 
> Bogofilter to operate on all the found "new" messages all at once, adding 
> its header to each, and keeping them in the same file names, all in one 
> fell swoop?

What you're doing sounds like its requires processing on each individual
email beyond a simple "score this email" -- you're actually writing
information to the file.

> (I have a feeling that "batch" mode is what I want, but I'm not sure how to 
> make that work on separate messages rather than one big input stream. I'm 
> also very hazy on the difference between "-b" and "-B"....)

I use "-B *" to do an operation on all the emails in my current
directory.  But I only use it to print out the spam score or register
them as spam/nospam.

> Any advice or insight is appreciated.

If you have IMAP access to the server I would make up a "spam" directory
and instead of putting the spam score in the header move the spam to
that folder.  However that doesn't work out so well with POP.

Chris



More information about the Bogofilter mailing list