procmail
[Top] [All Lists]

Re: a ^FROM like ^TO

1996-12-09 16:52:34
Timothy Luoma asked,

| This has probably been mentioned before, but is there (or could  
| there be) a macro "^FROM" which would work like the macro "^TO"  
| does?

There is no such token, but one can define a variable that matches what such
a token would expand to and then use it in conditions of later recipes (with
the "$" modifier); I think Alan already has something like that somewhere in
his library.

The advantage is that you could customize its definition to what you need
rather than relying on what's compiled in; the drawback is that the rest of
any regexp that contains that variable would also be subject to "$" interpre-
tation, so you might need to prefix some characters with backslashes or put
them inside brackets to prevent such interpretation where you don't want it.

Something like this would be a good start:

 FROM="(^((X-(Envelope-)?)?(Apparently-|Resent-)*(From|Reply-To|Sender):\
       (.*[^-a-z0-9_])?|From ([^        ]*[-_(_at_)!(_dot_)])?))"

The extra outer layer of parentheses are so that one can use forms like
${FROM}* or ${FROM}+ or ${FROM}?.

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