Re: killfile, anyone? - was: someone shouting expletives
on Fri, Mar 28, 2003 at 09:50:47AM +0100, Nicolas Kratz (nick@ikarus.dyndns.org) wrote:
> On Thu, Mar 27, 2003 at 07:16:07PM -0800, Paul Johnson wrote:
> > Mutt has no filtering options, as do most traditional (ie, not
> > Windowsish) MUAs. You want procmail. If you don't want to have to
> > learn procmail just for this one instance, also get dotfile-procmail.
> > You can then run dotfile and select the procmail options ot set up and
> > generate a procmailrc.
>
> Sorry, my question was insufficiently worded. I'm already
> using procmail to feed stuff through spamassassin and sorting the
> various mailing lists into their mboxes.
>
> What I am thinking about is a set of macros/key bindings in mutt to
> automagically add people to a killfile and purge all their crap from my
> mbox. Then advise procmail to look at the killfile, weeding out even
> before it hits spamassassin.
$ apt-cache install spamfilter
I add the following script (symlinked as
[wbg]l-{add,add-dom,ck,ck-all,list,help}) to add addresses to a
whitelist/blakclist. It's structured for maildir style mailboxes,
though I've rigged it for mbox in the past.
------------------------------------------------------------------------
#!/bin/sh
# black/white/grey list generator
# '-a' == append to appropriate list
# TODO:
# *-add: add name to list
# *-ck: check if name is on list
# *-list: show list
# *-add-dom: add domain to list
PATH=/usr/local/bin:/usr/bin:/bin
prefix=~/.procmail/etc
# Hosts to exclude from blacklisting/blocking, pipe-delimited for egrep
# matching.
excl_smtp_hosts="netcom.com|earthlink|mindspring"
function parse(){
/usr/local/bin/mail-dom-addr.sed |
egrep -v "^d: .*($excl_smtp_hosts)"
}
function parse_addr(){
parse | grep '^a: ' | cut -d ' ' -f 2-
}
function parse_dom(){
parse | grep '^d: ' | cut -d ' ' -f 2-
}
function list(){
parse
}
function list_add(){
if ! [ -f $prefix/$list.db ]; then
echo "error: $cmd spamfilter $list.db does not exist" 1>&2
exit 1
else
for addr in $( parse_addr )
do
if ! grep "^$addr\$" $prefix/$list.db 1>/dev/null; then
echo $addr >> $prefix/$list.db ||\
echo "error: adding $addr to $list failed" 1>&2 &&\
echo "$addr added to $list"
else
echo "already ${list}ed: $addr"
fi
done
fi
}
function list_add_dom(){
if ! [ -f $prefix/$list.db ]; then
echo "error: $cmd spamfilter $list.db does not exist" 1>&2
exit 1
else
for dom in $( parse_dom )
do
if ! grep "^$dom\$" $prefix/$list.db; then
echo $dom >> $prefix/$list.db ||\
echo "error: adding $dom to $list failed" 1>&2 &&\
echo "$dom added to $list"
else
echo "already ${list}ed: $dom."
fi
done
fi
}
function list_ck(){
for addr in $( parse_addr )
do
if grep -i $addr $prefix/$list.db; then :
else echo "not found: $addr" 1>&2
fi
done
}
function list_ck_all(){
for addr in $( parse_addr )
do
if grep -i $addr $prefix/*list.db; then :
else echo "not found in any list: $addr" 1>&2
fi
done
}
function list_list(){
${PAGER:-less} $prefix/$list.db
}
function list_list_all(){
more $prefix/*.db | ${PAGER:-less}
}
function list_help(){
cat <<- EOF
black/white/grey list spamfilter management.
[bwg]l: show addresses and/or domain(s) in $list.
[bwg]l-add: add address(es) to list $list.
[bwg]l-add-dom: add domain(s) to list $list.
[bwg]l-ck: show address(es) on list $list.
[bwg]l-list: show list $list.
EOF
}
# which list do we want?
cmd=$( basename $0 )
case $cmd in
bl*) list=blacklist;;
wl*) list=whitelist;;
gl*) list=greylist;;
*) echo "error: $cmd not recognized 1>&2"; exit 1 ;;
esac
# which command are we?
case $cmd in
[bwg]l) list ;;
[bwg]l-add) list_add ;;
[bwg]l-add-dom) list_add_dom ;;
[bwg]l-ck) list_ck ;;
[bwg]l-ck-all) list_ck_all ;;
[bwg]l-list) list_list ;;
[bwg]l-help) list_help ;;
*) echo "error: $cmd not recognized 1>&2"; exit 1 ;; # should never happen
esac
------------------------------------------------------------------------
Peace.
--
Karsten M. Self <kmself@ix.netcom.com> http://kmself.home.netcom.com/
What Part of "Gestalt" don't you understand?
The truth behind the H-1B IT indentured servant scam:
http://heather.cs.ucdavis.edu/itaa.real.html
Reply to: