Evolution has a feature for marking e-mail as junk. This will set an IMAP keyword “Junk” on those messages. On my mail server I run Dovecot as IMAP server and Spamassassin through Amavis to filter spam. How could I get Spamassassin to learn that all e-mails marked as junk in Evolution are spam? With a shell script, of course. I currently run it as root but maybe it is possible to give the amavis user permissions to read my Maildir…
#!/bin/sh if [ `whoami` != 'root' ]; then exec sudo $0 $@ fi find ~david/Maildir -name dovecot-keywords | ( while read keywords; do DIR=`dirname $keywords` #echo $DIR >&2 # XXX only supports 10 keywords CHAR=`awk '$2 == "Junk" { print $1; quit; }' $keywords | tr '0-9' 'a-j'` if [ "$CHAR" ]; then find $DIR/cur $DIR/new -regex "[^,]*,[^,]*$CHAR.*" | xargs sa-learn --dbpath /var/lib/amavis/.spamassassin/ --spam fi done ) /etc/init.d/spamassassin reload
Helpful pages: Maildir format used by Dovecot, Spamassassin with amavis: Tips and tricks.