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

Re: Archiving



On Fri, Feb 13, 2009 at 03:25:04PM +0100, Andreas Kalex wrote:

> > (Except for spam; that goes to bogofilter for accounting and then
> > discarded.)
> How do you implement it in the muttrc? Or do you use tools like procmail.

I have those lines in my muttrc :
macro pager "\Cxs" "<pipe-message>bogofilter -s && echo \"Mail registered as 
spam.\"<enter>" "Mail registered as spam"
macro index "\Cxs" "<pipe-message>bogofilter -s && echo \"Mail registered as 
spam.\"<enter>" "Mail registered as spam"
macro pager "\Cxus" "<pipe-message>bogofilter -Sn && echo \"Mail unregistered 
as spam.\"<enter>" "Mail unregistered as spam"
macro index "\Cxus" "<pipe-message>bogofilter -Sn && echo \"Mail unregistered 
as spam.\"<enter>" "Mail unregistered as spam"
macro pager "\Cxg" "<pipe-message>bogofilter -n && echo \"Mail registered as 
good.\"<enter>" "Mail registered as good"
macro index "\Cxg" "<pipe-message>bogofilter -n && echo \"Mail registered as 
good.\"<enter>" "Mail registered as good"
macro pager "\Cxug" "<pipe-message>bogofilter -Ns && echo \"Mail unregistered 
as good.\"<enter>" "Mail unregistered as good"
macro index "\Cxug" "<pipe-message>bogofilter -Ns && echo \"Mail unregistered 
as good.\"<enter>" "Mail unregistered as good"
macro pager "\Cxt" "<pipe-message>bogofilter -t<enter>" "Check"
macro index "\Cxt" "<pipe-message>bogofilter -t<enter>" "Check"

For instance, I can tell bogofilter "this mail is a spam" by pressing :
Ctrl+x then the 's' key.

As I use a maildir, I also wrote a little wrapper of bogofilter :

$ cat bin/bogofilter-wrapper.sh
#!/bin/sh

mailbox="$1"
spambox="$2"
[[ ! -z "$2" ]] && spambox='[Gmail].Spam'

src="/home/nicolas/Mail/${mailbox}/INBOX/new/"
dest="/home/nicolas/Mail/${mailbox}/${spambox}/new/"


echo "Looking for spam."

spam=0
for mail in $(find "${src}" -type f) ; do
        bogofilter -I "${mail}" && {
                echo "Spam found : $mail"
                spam=$((spam+1))
                mv "$mail" "$dest"
        }
        total=$((total+1))
done

echo "Total spam found : $spam/$total"
#--------EOF---------

I call this script like this from mutt :
macro pager "\Cwf" "<pipe-message>bogofilter-wrapper.sh 
'nicolas_MAILBOX_gmail.com' '[Gmail].Spam'<enter>" "Filter mails"
macro index "\Cwf" "<pipe-message>bogofilter-wrapper.sh 
'nicolas_MAILBOX_gmail.com' '[Gmail].Spam'<enter>" "Filter mails"

-- 
Nicolas Sebrecht