procmail
[Top] [All Lists]

Re: subject-based killfile

1996-12-07 09:26:47
I would like to setup a _sorting_ (not bouncing) recipe for certain  
Subjects.

Well, actually, it would be based on _parts_ of subjects.  I would  
like to be able to do this based on keywords found in the subject,  
such as:

subscribe
unsubscribe
virus
try this
credit card
money
1-900
cmsg cancel
!!!
***
+++

I don't want to bounce these, just put them in a folder so I can  
make sure they are messages to delete.

I was going to setup a file to do this, but since I'm not matching  
full subjects, but only parts, I wondered if I had to do this within  
.procmailrc with something like this:

:0:
* ^Subject:.(*ubscribe|\
              *virus|\
              *try this|\
              *cmsg cancel|\
              *credit cards|\
              *money|\
              *1-900)
Trash


of course this could get very long, which is why I wanted to do it  
in a file, but can I do that without having to match the entire  
subject??

Sure.  Something like this should work:

        #Pull "Subject:" out of incoming email.  Make sure you have
        #already defined FORMAIL.
        SUBJ=`$FORMAIL -zx 'Subject: '`
        #Define the path for the list of subjects below.
        SUBJLIST=

        :0
        * ? echo "$SUBJ" | egrep -i -f $SUBJLIST
        Trash

Keep in mind when you are trying to match parts of "Subjects:" the 
difference between REGEXPs and literal strings and you should be set.  
One more thing, make sure the version of GREP/EGREP you use will support 
the length of file you will make your "list of subjects".  Some (older) 
GREPs crap out if the file gets longer than a few lines.  I've found GNU 
GREP v2.0 works well.

Thanks again

TjL

--
                Tj Luoma (luomat(_at_)peak(_dot_)org)
                http://www.next.peak.org/~luomat

Lates!
------------------------------------
Tim <bodysurf(_at_)netcom(_dot_)com>
"Finger" for PGP v2.6.3ia Public Key

<Prev in Thread] Current Thread [Next in Thread>