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/learn-spam.sh
———–
#!/bin/bash
sa-learn –spam [path to dovecot Maildir]/.Junk/cur
———–

#chmod +x /root/learn-spam.sh
#crontab -e

crontab file
———–
# run each day at 01:00 AM the learn-spam.sh script
0 1 * * * /root/learn-spam.sh
————

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

Specify Facebook App ID and Secret in Super Socializer > Social Login section in admin panel for Facebook Login to work

Specify LinkedIn Client ID and Secret in Super Socializer > Social Login section in admin panel for LinkedIn Login to work

Specify GooglePlus Client ID and Secret in Super Socializer > Social Login section in admin panel for GooglePlus Login to work

Specify Vkontakte Application ID and Secret Key in Super Socializer > Social Login section in admin panel for Vkontakte Login to work

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>