Here's a script I use to run sa-learn.   How I manage mail is:

  everything is in maildir for dovecot, delivered to via procmail
  SA score >= 6  to /dev/null
  SA score >= N to .spam.N for N in 1..5
  other taggging from foo to .spam.foo
  ham found in .spam.N filed back to INBOX
  spam found in regular folders refiled to .spam.manual
    or sometimes .spam.complaints if I'm tracking for blacklist submission

  cron runs the script daily


The script has cruft from when I used mh folders.

The script is slightly redacted, but it should be easy enough to repair.


#!/bin/sh
# $Id: do-spam,v 1.14 2008/06/16 20:47:21 gdt Exp $
# Copyright 2005-2008 Gregory D. Troxel.  Permission granted to copy
# under 3-clause BSD license.

cd $HOME
if [ -d IMAP ]; then
    # find all maildirs
    find IMAP -type d | while read dir; do \
        hamp=--fail-with-error
        nosync=--nosync
        skip=no
        if [ -d "$dir"/cur ]; then
            case "$dir" in
                IMAP/.spam.complaints|.misc.daemon)
                    hamp=--forget; nosync=;
                    ;;
                IMAP/.spam*)
                    hamp=--spam
                    ;;
                IMAP/.Trash|"IMAP/.Deleted Messages")
                    # This is deleted ham, by policy.
                    hamp=--ham
                    ;;
                *)
                    # Default is ham.
                    hamp=--ham
                    ;;
            esac
            if [ "$skip" = no ]; then
                echo -n "PROCESSING $hamp in $dir: "
                sa-learn $nosync $hamp --dir "$dir"/cur
            else
                echo "SKIPPING $dir"
            fi
        fi
    done
else
    sa-learn --nosync --ham --dir Mail/inbox
    sa-learn --nosync --spam --dir Mail/spam-probable
    sa-learn --nosync --spam --dir Mail/spam-certain
fi

sa-learn --sync

# REMOVE SELF AWL

uname=`id -un`
hname=`hostname`
[EMAIL PROTECTED]

case uname in
    gdt)
        ADDRS="$ADDRS [gdt's other addresses]"
        ;;
    #[more user blocks]
esac

for addr in $ADDRS; do
    echo Removing $addr from AWL:
    spamassassin --remove-addr-from-whitelist=$addr
done

Attachment: pgpePDPCeuYQR.pgp
Description: PGP signature

Reply via email to