procmail
[Top] [All Lists]

Re: Mail body

1997-12-12 17:09:51
At 10:25 AM 12/10/97 -0600, Philip Guenther wrote:
Marco Pirovano <marco(_dot_)pirovano(_at_)uni-bocconi(_dot_)it> writes:
I want to use procmail to do a simple filter:

if {in the body of the mail there is "students.uni-bocconi.it" purge the
mail}
else { send the mail to a specific address}

Do I nedd to use same script in perl or other, or can I do it with 
procmail commmands ?

No need for perl.  Procmail can do basic if-else processing and it can
search in the body of the message using the 'B' flag:

      # If the phrase "students.uni-bocconi.it" occurs in the body, with
      # word boundaries on each end (so that "students.uni-bocconi.italy"
      # won't match), then /dev/null the message.  The leading parens
      # protect that first backslash from being processed differently.
      :0 B
      * ()\<students\.uni-bocconi\.it\>
      /dev/null

      # If the above recipe failed, then we're here.  Forward the message.
      # We could use the 'E' flag, but it's superfluous because if the
      # previous matchs, procmail will exit after delivering to /dev/null.
      :0
      ! some(_at_)specific(_dot_)address

Q:  1. What do the ()'s in the * ()\<etc... line do???

    2. I assume \< and \> are the word boundaries?

    3. Why aren't {}'s required for the :0 + ! some(_at_)specific(_dot_)address 
part???

    4. Is the blank space between the /dev/null and next :0 lines necessary?

Thanks.

Eric

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