procmail
[Top] [All Lists]

Re: .procmailrc processing of To: field

1997-03-12 11:37:09
Mike de Laine asked why this recipe doesn't work:

| :0:                             # Anything to test 
| * ^To:(_dot_)mike+test(_at_)*
| test                            # will go to $MAILDIR/test

First, "^To:." assumes that the address will be in the To: header, first in
the header, preceded by exactly one space, and never placed after a name nor
into angle brackets.  Better to use ^TO or, if your procmail version is
recent enough, ^TO_.

Second, that trailing asterisk doesn't mean in a regexp what it means in
shell globbing, and you don't have to match the entire line in a regexp the
way you have to match the entire filename in shell globbing.  An asterisk
means "zero or more of the previous unit", so "@*" matches null, or @, or
@@, or @@@, or @@@@, and so forth; all it does is mean that the at-sign
doesn't have to be there, so you are getting the same effect with "@*"
at the end as you would with leaving both the at-sign and the asterisk off.

The real trouble is that you are trying to use a plus sign to match a plus
sign. "+" is magic for "one or more of the previous unit," and a unit, in the
absence of parentheses or brackets, is one character.  So "e+" will match e,
ee, eee, eeee, and so forth, but it will not match e+.  To make a plus sign
match a literal plus sign, you need to escape it with a backslash or enclose
it in brackets:

 mike\+test
or
 mike[+]test

So try this:

  :0: # use ^TO if your procmail doesn't support ^TO_
  * ^TO_mike\+test
  test

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