Make spamassassin learn spam messages right from mutt

If you’re using mutt and you also have your private e-mail server running spamassassin, then you’ll see some spam messages still getting through the pipeline, with scores just below the default 5.0. So here’s the cure: use sa-learn on the server in order to train spamassasin bayesian filter and help it increase score on real spam.

You already have:

  • offlineimap syncing your remote mailbox with a local folder from where mutt reads the messages.
  • Junk folder in your IMAP mailbox, and server-side SIEVE scripts automatically move spam messages into this folder.

The big picture:

  • Manually move the messages you want classified as spam into the Junk folder; offlineimap will automatically send them to the server upon next sync operation
  • Have a cron-job on the server call the sa-learn utility on the Junk folder

Detailed steps:

file .muttrc
macro index ,j “:set confirmappend=no delete=yes auto_tag=yes\n=Junk\n:set confirmappend=yes delete=ask-yes\n” “Send message to Junk folder”

Log-in to the mail server then:

file /root/
sa-learn –spam [path to dovecot Maildir]/.Junk/cur

#chmod +x /root/
#crontab -e

crontab file
# run each day at 01:00 AM the script
0 1 * * * /root/

VoilĂ  ! Each time you’re on a spam message in mutt, just hit ,j and the next day you’ll get more messages automatically classified as spam in the Junk folder.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>