procmail
[Top] [All Lists]

Re: Searchhing for words in external word list?

2008-12-14 13:23:53
On (07:42 12/12/08), Dallman Ross <dman(_at_)nomotek(_dot_)com> put forth the 
proposition:
On Thu, Dec 11, 2008 at 06:06:54PM -0800, Professional Software
Engineering wrote:

At 20:46 2008-12-11 +0100, Dallman Ross wrote:

The rest of Sean's advice -- most snipped here -- was fine, but
this part is not correct.  The curly braces do not cause quoting!

Argh, you're right. Too little sleep for me. I make it a habit of encapsulating the variable names for expansion with braces:

        {$\BADWORDS}

Duh.

I can't sleep either.  Just got up after lying in bed for 3 hours
without sleeping.

I don't follow your clarification, however.  That wouldn't work.

% procmail DEFAULT=/dev/null 'FOO=foo|bar' 'BAR={$\FOO}' 'LOG="BAR is $BAR"' /dev/null < /dev/null BAR is {()foo\|bar}

Perhaps you meant you use curly braces afterward as a reminder to
yourself that that var is quoted?  E.g.,

% procmail DEFAULT=/dev/null 'FOO=foo|bar' 'BAR=$\FOO' 'LOG="BAR is ${BAR}"' /dev/null < /dev/null BAR is ()foo\|bar

Dallman

After all this playing around I've decided to go with a whitelist based on
domain. It will mean having to check probable-spam folder for legit mail
not and again but on the whole I think that's better.

This is how I'm doing it:

# do filtering against whitelist
FROM=`formail -xFrom: | cut -f 2 -d '<' | cut -f 2 -d '@' | cut -f 1 -d
'>'`
:0
* ! ? grep -F -i -x -q "$FROM" $HOME/.whitelist
probable-spam

And I have this after all my mailing list and other filters from known
addresses. I have a whitelist keybind in mutt which runs a shell script to
add to the whitelist file:

macro       pager       \W              |whitelist\n
macro       index       \W              |whitelist\n

whitelist shell script:

########################
#!/bin/sh

whitelist="$HOME/.whitelist"
TMP="/tmp/whitelist.tmp"

[[ ! -f $whitelist ]] && touch $whitelist

cat /dev/stdin > $TMP
address=$(cat $TMP | formail -xFrom: | cut -f 2 -d '<' | cut -f 2 -d '@' | cut -f 
1 -d '>')

if [[ $(cat $whitelist | grep -x $address) != "" ]]
then
    {
        printf "\e[01;31m%b %b\e[m\017\n" $address "already in whitelist"
    }
else
    {
        printf "\e[01;32m%b %b\e[m\017\n" $address "whitelisted"
        echo $address >> $whitelist
    }
fi

sleep 1
########################

I haven't found any problems yet. Perhaps this will be of use to others. I 
chose to check
by domain name but I'm sure it could be adapted for specific addresses.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

--
Rudin's Law:
        If there is a wrong way to do something, most people will do it
every time.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail