Maildir format

Chris Wilkes cwilkes-bf at ladro.com
Tue Dec 9 19:21:22 CET 2003


On Tue, Dec 09, 2003 at 06:46:08PM +0100, Micha? Wieja wrote:
>
> Sorry for silly question, but how to 'teach' bogofilter with mail
> stored in Maildir format ?

That's not a silly question at all!  What I do is the following:

  for i in ./Maildir/.good/cur/*; do
    bogofilter -n -I $i;
  done
  
  for i in ./Maildir/.spam/cur/*; do
    bogofilter -s -I $i;
  done

provided that you have email seperated into a "good" and "spam" folder.
If you don't and its all in one big Maildir but you want to seperate it
out into 3 different zones of "definately good" "on the fence" and
"probably bad" you could do the following in bash:

  cd ./Maildir/cur
  d=/tmp/BF
  export spam=$d/.spam/
  export maybe=$d/.maybe/
  export good=$d/.good/
  maildirmake $d
  maildirmake $spam
  maildirmake $maybe
  maildirmake $good
  for i in *; do
    echo $i;
    w=$(bogofilter -v -I $i | cut -d, -f3 | cut -d\= -f2);
    if   [[ $w < 0.49 ]]; then
      cp $i $good/new;
    elif [[ $w > 0.49 && $w < 0.80 ]]; then
      cp $i $maybe/new;
    else
      cp $i $spam/new;
    fi
  done

Then see how it did:

  ls | wc -l
  for i in good maybe spam; do
    echo -n "$i ";
    ls /tmp/BF/.$i/* | wc -l;
  done

Then with a minimal /tmp/BF/.muttrc file:
    set spoolfile="/tmp/BF/"
    set move=no
    macro index S s!/.spam/<return><return>
    macro index G s!/.good/<return><return>
you can do a "mutt -F /tmp/.muttrc" and do a "!.spam" to see your spam,
"!.maybe" to see the maybes and "!.good" to see the good ones.  Move
them to the spam folder by hitting S, and to the good by hitting G.

I made up the splits of 0.49 and 0.8 -- try varying that if it is way
offbase.  Then proceed like above with the training.

Chris




More information about the Bogofilter mailing list