procmail
[Top] [All Lists]

Re: About mails not addressed to me personally

1997-10-17 09:58:02
On Fri, 17 Oct 1997 19:03:19 +0300 (EET DST),
Kimmo Jaskari <kimmo(_at_)alcom(_dot_)aland(_dot_)fi> wrote:
Right now I have the following recipe at the end of my procmailrc:
:0:
* ^TO.*kimmo@
| $FORMAIL -A"X-Sorted: Default" >>$DEFAULT

Standard rant about how ^TO should not be followed by .*

I noticed, however, that Ariel has the following way of doing
approximately the same thing in her sample procmailrc:
* ^(To:|Cc:).*(login(_at_)shelldomain\(_dot_)com|\
         (_dot_)*(_at_)customdomain\(_dot_)com|\
         login(_at_)otherdomain\(_dot_)net)
| $FORMAIL -A"X-Sorted: Default" >>$DEFAULT
The latter approach lets you add adresses that don't start with the
same name before the @, right? Is that the only functional difference

I'm not sure what you mean here. (To:|Cc:) [which could be written
(To|Cc): if you want to save a precious byte :-] will catch many fewer
headers than ^TO, but that doesn't appear to be what you're asking. 
If you're wondering about the stuff in parens, this is perfectly
allowable in either case; you could use ^TO(kimmo|jaskari|kjaskari)@
or ^TO(kimmo|[^@        ,<>]*(_at_)ooland\(_dot_)net) or whatever. ^TO is just a
complicated regular expression in disguise; it doesn't fundamentally
change anything in how you do the matching. (If you have a new enough
version of Procmail, you probably want ^TO_ instead of ^TO, though.)
This goes for the whitespace as well. 

In other words, Ariel could equally well (remembering that this will
include Resent-To: etc as well as To: and Cc:) have written

    *^TO(login(_at_)shelldomain\(_dot_)com|\
        (_dot_)*(_at_)customdomain\(_dot_)com|\
        login(_at_)otherdomain\(_dot_)net)

and you could equally well use something more or less like it. BTW, if
you're paranoid, avoid .* here, too -- the above would allow mail To:
spamvictims(_at_)cyberpromo(_dot_)com (comment which mentions customdomain.com)
[for lack of a better example to scare you with ...] whereas a more
cautious regexp would not. (The ^TO macro goes to some lenths to
ensure it matches only in the actual address part, not comments etc;
and the ^TO_ macro even more so.)

The procmailrc(5) manual page contains the expansion of ^TO and ^TO_
-- and if that's not enough, the archives should contain plenty of
better examples than I have come up with here.

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