procmail
[Top] [All Lists]

Re: procmail condition question

1996-09-11 09:02:25
  > I am certifiably not a programmer, but I have assembled the following, and 
  > it works perfectly to send an autoreply to anyone writing from a domain 
  > named in the condition line:
  > 
  > # this nukes mail from anyone at uce-prevalent domains
  > :0 w :
  > * 
  > ^From.*@(cyberone\.com|truenet\.net|netlnnx\.com|sparknet\.net|ez1\.com|  
  > pcspecialist
  > s\.com|ix\.netcom\.com|gil\.com\.au|znet\.com|uran\.net|loop\.net|tlg\.n  
  > et|interramp\.
  > com|flinet\.com|usaads\.com|bigprofits\.com|cvcom\.com)
  > |/usr/home/estone/auto_reject_dom

Another way to do this is to create a file of addresses the mail from
which are to be filtered.  Let's call this file "reject-list".  The
recipe to do this would be:

  # Set PATH to include where our filter comes from, so the recipe looks nicer
  PATH=$PATH:/usr/home/estone

  :0 w:
  * ? formail -rtzxTo: | fgrep -s -f reject-list
  |auto_reject_dom

By the way, I used "w" only because you did; if you don't care about an
exit code from the filter, then don't use it.

And, if the filter does not update files or do other kinds of record
keeping, then there is no reason to use a temporary lockfile (ie: the
trailing ":").

  > What I want to learn how to do is to create a similar, single line
  > condition that selects all mail with any of a list of words in the
  > Subject line. Believe it or not, I've run "man procmailex" twenty
  > times, and I still don't know how to do it...

Similar technique.  Create a list of subject keywords and place them in
the file "keywords", and use the following recipe:

  :0 w:
  * ? formail -zxSubject: | fgrep -s -f keywords
  |some-filter

If you would like the keyword list to be more versatile, say, make them
regexps, so you can detect a combination of phrases, like: "Free money",
"Free cash", "Absolutely free", etc.   Then place regexps in the file,
let's call it "keyword-regexps", and use the recipe like this:

  :0 w:
  * ? formail -zxSubject: | egrep -s -f keyword-regexps
  |some-filter

_____________________________________________________________________
Alan Stebbens <stebbens(_at_)sgi(_dot_)com>      http://reality.sgi.com/stebbens

<Prev in Thread] Current Thread [Next in Thread>
  • Re: procmail condition question, Alan Stebbens <stebbens(_at_)anywhere(_dot_)engr(_dot_)sgi(_dot_)com> <=