<<< Date Index >>>     <<< Thread Index >>>

3 Mutt binds for SpamAssassin, if anyone is looking ;)



Hello Mutt users ;)

I was doing a lot of searching for Mutt macros for using the sa-learn program
that comes with SpamAssassin. I found some, but they are very simple and
incomplete. They do things right, but I came up with 3 macros that have some
more automation (no ``Press enter...'', etc.) Include this in you're .muttrc
file:

## NOTE: Make sure that auto-wrapping is not enabled (:set textwidth=0) before
#       pasting the following text in! If the macro was wrapped, Mutt will give
#       you errors about unknown functions, blah blah blah
#       All macros (macro index ...) should stay on ONE LINE
##

# Pressing a key will do this in the index:
# S (shift-s): Learn the message as spam; Copy message to spam mailbox; Mark the
# (original) message to be deleted.
# H (shift-h): Learn the message as ham (_not_ spam)
# E (shift-e): Re-build the SpamAssassin database

# Bind a spam macro to do this for us:
#       1) Pipe the spam to sa-learn without rebuilding the database
#               - use loging
#       2) Copy the message to the spam folder
#       3) Delete the message from the original folder
macro index S '<enter-command>unset wait_key<enter><shell-escape>date >> 
~/Mail/.sa-learn.log<enter><pipe-message>sa-learn --spam --no-rebuild -D >> 
~/Mail/.sa-learn.log 2>&1 &<enter><copy-message>~/Mail/spam/ 
<enter><enter><delete-message><enter-command>set wait_key=yes<enter>'

# now make another set, but for ham (not spam) messages.
# tell sa-learn to learn ham message. dont delete it or move it.
macro index H '<enter-command>unset wait_key<enter><shell-escape>date >> 
~/Mail/.sa-learn.log<enter><pipe-message>sa-learn --ham --no-rebuild -D >> 
~/Mail/.sa-learn.log 2>&1 &<enter><enter-command>set wait_key=yes<enter>'

# a macro that tells SA to rebuild its database
macro index E '<enter-command>unset wait_key<enter><shell-escape>date >> 
~/Mail/.sa-learn.log<enter><shell-escape>sa-learn --rebuild -D >> 
~/Mail/.sa-learn.log 2>&1 &<enter><enter-command>set wait_key=yes<enter>'

If you dont want to log the output of sa-learn, then remove all occurences of
``<shell-escape>date >> ~/Mail/.sa-learn.log<enter>'' and
``>> ~/Mail/.sa-learn.log 2>&1'' If you dont want to have debug information in
the output, remove the ``-D'' flag from sa-learn.

All spam will be copied to ~/Mail/spam/ (a Maildir directory,) if you use a
different place to store mail, shange that as neccesary.

I hope that saves someone some time :)

-- 
andrei bazhgin | aftermath | programmer | nan2d.com