procmail
[Top] [All Lists]

Re: Matching in the Header vs Recipient

1998-11-04 19:04:03
Jacques Gauthier <jacques_g(_at_)yahoo(_dot_)com> writes:
If I want a recipe done for a particular recipient ex:

COOKIELOCK = /tmp/iwannacookie
:0:$COOKIELOCK
* ^To: .* (cookiemonster(_at_)mydomain)
| foo > foobar ; 

Is it safer to do:

* H ?? (cookiemonster(_at_)mydomain)
| foo > foobar ; 

I want to get messages to cookiemonster in both
To: and CC: field.

Procmail has a builtin regexp to handle this, made availible via the
^TO_ token and used in a condition like this:

        * ^TO_cookiemonster(_at_)mydomain

This will match messages which have a "destination header" that
contains the address cookiemonster(_at_)mydomain(_dot_)  The _current_ list of
destination headers is:

    To:         Resent-To:      Original-To:    Original-Resent-To:
    Cc:         Resent-Cc:      Original-Cc:    Original-Resent-Cc:
    Bcc:        Resent-Bcc:     Original-Bcc:   Original-Resent-Bcc:
    X-Envelope: Apparently-To:  Apparently-Resent-To:

Just use ^TO_ and save yourself the typing.


Now for the catch:

^TO_ was introduced in procmail version 3.11pre4.  If you have a
version before that you'll have to use ^TO instead (without the '_').
That token gives you a regexp that is more liberal, matching any of
those header listed above that contain the _word_ that follows the
^TO.  For example, ^TObar will match "To: a-bar", while ^TO_bar won't.
However, neither will match "To: foobar" (bar is not preceded by a
non-alphanumeric character).

If that would be a problem, then you should either a) upgrade to
3.11pre7 (the current version); or b) copy the regexp for ^TO_ from the
3.11pre7 procmailrc(5) manpage and use it directly.  The former is
to be prefered, as 3.11 has many bugfixes and other enhancements.


Philip Guenther

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