procmail
[Top] [All Lists]

Re: dispatching messages on a To: and Cc: list ?

1997-05-13 11:58:00
Denis Roegel asked,

| My main problem is that I want to duplicate messages
| sent to several addresses, and only sometimes put them
| back in the default mail box.

... illustration deleted ...

My first idea is that, for each recipient, instead of simply filing or
forwarding the item, you should also append [a space and] the recipient's
identifier to a variable.  (We can't use $LASTFOLDER for this because its
previous value is lost with every delivery of a copy.)
  
  FOUND # make sure it starts out unset

  :0c:
  * ^TOa
  folder-a
   :0A
   { FOUND="$FOUND a" } # first one could be just { FOUND=a }

  :0c:
  * ^TOb
  folder-b
   :0A
   { FOUND="$FOUND b" }

  :0c:
  * ^TOc
  folder-c
   :0A
   { FOUND="$FOUND c" }

and so forth.

Then when all such comparisons are done, check on the contents of that
variable.  For example, if anything addressed to both "b" and "d" should
not be stored anywhere else, unless it was also addressed to "f", in which
case we want to keep it around for the rest of .procmailrc,

  :0h
  * FOUND ?? \<b\>
  * FOUND ?? \<d\>
  * ! FOUND ?? \<f\>
  /dev/null

The \< and \> are there because I'm sure the identifiers will not all be
single characters and one might possibly be a substring of another.

(Since b will always precede d if both are present, the first two conditions
 could be written this way:

 * FOUND ?? \<b (.* )?d\>

 but I think the first way is easier to type in, read, and maintain.)

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