procmail
[Top] [All Lists]

Re: counting and limiting emails

1996-10-25 11:34:08
Compare the clarity of these two recipes:

The "easy, but expensive" one:

|     SENDER=`formail -rtzxTo:`

The "procmail-way"

   :0
   * ! ^Reply-To: *\/[^ ].*
   * ! ^From: *\/[^ ].*
   * ! ^Sender: *\/[^ ].*
   * ! ^Return-Path: *\/[^ ].*
   * ! ^From +\/[^ ].*
   { SENDER }  # unset it and don't bother responding
   :0E
   { SENDER="$MATCH"

Which do you find more convenient to use?

Stephen, it would sure be nice if we could use "m4" or some kind of
macro facility.  Imagine defining a "GET_SENDER" recipe (using m4 syntax):

    changequote([[, ]])
    changecom(##)
    ## define GET_SENDER(VAR) to set VAR to the best address of the SENDER
    define(GET_SENDER, [[
            :0
            * ! ^Reply-To: *\/[^ ].*
            * ! ^From: *\/[^ ].*
            * ! ^Sender: *\/[^ ].*
            * ! ^Return-Path: *\/[^ ].*
            * ! ^From +\/[^ ].*
            { $1 }  # unset it and don't bother responding
            :0E
            { $1="$MATCH" }
        ]])

Then, to use it is fairly simple:

    GET_SENDER(SENDER)

Alan

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