Well, I needed to figure this one out, so I came up with what I think is a
reasonable solution, though perhaps a little crude. Thought I'd pass it along
comments or suggestions...
DOMAINRX = "(hotmail|aol)\.com"
* 1^1 ^TO_\/.*
* -1^1 MATCH ??@
*$ 1^1 MATCH ??(_at_)$DOMAINRX
* -1^1 ^TO_.*
This set of rules gives (hopefully) messages with just "@hotmail.com" or
"@aol.com" recipient addresses in the headers filtering into
"hotmail_or_aol_only" and messages with those addresses outside those domains
(though possibly containing some aol or hotmail addresses) going into
The way it does this is to count (negatively) the number of addresses by
the "@"s in the recipient headers, and then incrementing that count for each
address that matches DOMAINRX. It also increments that counter by one (just
once). This should give the desired positive score for messages which contain
only the desired domains... unless my logic is badly flawed.
I know that there could be "@" symbols elsewhere in the recipient headers that
aren't necessarily part of an address... but that doesn't happen all that often.
Anything else I might be missing, or suggestions that would make this better?
"Eric C. Hagberg" wrote:
Maybe I need to give a couple examples. The solution below doesn't cover
my requirements. I want to be able to specify that all mail containing
recipient addresses in those domains (but not containing _any_ other
domains in the addresses) gets put into a folder.
For example this set of headers:
To: bozo(_at_)aol(_dot_)com, theclown(_at_)hotmail(_dot_)com
should get caught by the correct recipe. However this set of headers:
To: bozo(_at_)aol(_dot_)com, someone(_at_)otherdomain(_dot_)com
should not get caught by the same recipe. Is that clear? It is easy to do
what you've almost specified - which is match all messages containing at
least one recipient in the specified domains. What is difficult (very, as
far as I can tell), is to capture messages containing only addresses in
the specified domains, but no others.
On Mon, 13 Sep 1999, S.Toms wrote:
On Mon, 13 Sep 1999, Eric Hagberg wrote:
eh> I've been trying to figure this one out, but can't seem to come up with
eh> a solution. Perhaps someone else out there has done this before...
eh> Is there a way to get procmail to filter messages that only contain
eh> addresses in a particlar domain or domains, but not any others. For
eh> example, if I wanted to capture all messages that contained @aol.com or
eh> @hotmail.com, but no other domains in the recipient addresses, is this
Not sure by what you mean by capturing, do you mean you want to only
receive mail from those addresses or do you want to not receive email from
If you want to receive only those, try something like the following:
If you don't want to receive them, try the same without the exclamation
S.Toms - tomas(_at_)primenet(_dot_)com - http://www.primenet.com/~tomas
S.u.S.E. Linux v6.1+ - Kernel 2.2.11
Human beings were created by water to transport it uphill.
Eric Hagberg, hagberg(_at_)ms(_dot_)com, (212)762-2558
Morgan Stanley, 750 Seventh Avenue, New York, NY 10019
Description: Card for Eric C. Hagberg