procmail
[Top] [All Lists]

Re: Correct format?

1997-12-09 09:24:49
On Tue, 9 Dec 1997 10:33:59 -0500, 
nauss(_at_)beryllium(_dot_)crs(_dot_)uc(_dot_)edu 
(Jeffrey L. Nauss) wrote:
:0:
* (^TO|^FROM)Friend(_at_)public(_dot_)COM
SPAM5.folder
Do I recieve a passing grade on this exercise? :-)

Sorry, no, there is no ^FROM macro. What you want is

    :0:
    * (^TO_|^From:(.*\<)?)friend(_at_)public\(_dot_)com\>
    SPAM5.folder

Longer explanation: ^TO (and ^TO_ in newer versions of Procmail) is a
special macro which, among other things, means it already contains the
trailing colon that you'd normally expect on a To: field. It also
means that this will match not only To:, but also Cc:, Apparently-To:,
etc etc. See the manual for the full scoop. If you really mean to
match only To: and From:, you want

    :0:
    * ^(To|From):(.*\<)?friend(_at_)public\(_dot_)com\>
    SPAM5.folder

The capitalization of "friend(_at_)public(_dot_)com" is irrelevant, unless you
use the D flag (in which case you also ought to take some measures to
make sure you accept all possible capitalizations of To and From, i.e.

    :0D:
    * ^([Tt][Oo]|[Ff][Rr][Oo][Mm]):(.*\<)?Friend(_at_)public\(_dot_)COM\>

but I guess you don't really want this so just ignore it if you think
it's confusing).

The trailing \> is not really necessary in this case*, but prevents you
from accidentally matching e.g. "public.community.net" when you really
want to match specifically only on strings that end with ".com".
Similarly, the (.*\<)? construct tries to tie the beginning of the
match to a word boundary (which is much less rigorous than what the
^TO_ macro does, but better than no bounding at all).

The FAQ <http://www.iki.fi/~era/procmail/mini-faq.html> attempts to
explain various parts of this, and has some other friendly tips as
well. 

/* era */

* because on today's Internet, naming a host public.comwhatever is
virtually equivalent to blocking yourself from a lot of places which
use filters which +don't+ check for word boundaries. We don't want to
be one of them, though. 

-- 
 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>