procmail
[Top] [All Lists]

Re: how to save the From, To: and Cc: fields in env. vars ?

1997-10-05 13:49:31
On Sun, 5 Oct 1997 22:14:24 +0200 (MET DST),
"Denis B. Roegel" <Denis(_dot_)Roegel(_at_)loria(_dot_)fr> wrote:
FROM=<value of From field>
TO=<value of To: field>
CC=<value of Cc: field>
How do I write this precisely ?

You grab them into MATCH and then pass that on to the variables you
want to save them in. (The whitespace in the square brackets consists
of one space and one tab; this is to strip any leading whitespace from
the values we grab.)

    :0
    * ^From:[   ]*\/[^  ].*
    { FROM="$MATCH" }

    :0
    * ^To:[     ]*\/[^  ].*
    { TO="$MATCH" }

    :0
    * ^Cc:[     ]*\/[^  ].*
    { CC="$MATCH" }

If any of those fields is not present, the corresponding variable will
remain unchanged (unset, unless you already set it to something else).

I want to have these values in environment
variables, for I want to call an external program with
them as parameters (and also with the value of FOUND,
mentionned in previous posts).

If it's a program you write yourself, you might seriously consider
adding primitive mail header parsing to the program itself.

This obviously doesn't attempt to parse the fields in any way (such as
remove any comments from the To: field, i.e. reduce "era eriksson
<era(_at_)iki(_dot_)fi>" to just "era(_at_)iki(_dot_)fi") but I hope that's not 
what you
were asking for, either.

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

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