procmail
[Top] [All Lists]

Re: Sort into mailing list folders ...

1998-09-25 12:27:44
Gunther Schadow wrote,

[He receives items that are crossposted to several mailing lists, and he
 belongs to more than one of them, so he gets multiple copies of such items,
 and they all are stored in the folder for the list that has the earliest
 recipe in his rcfile.]

| I imagine that in order to sort the crossposted mail correctly one
| would have to do two things:                         ^^^^^^^^^

There's no one way that is "correct", but let's see what we can do about
sorting it as you wish:

The way I read these two ...

| (1) after one match was found, the matching To/Cc address ought to be
| removed from the To/Cc line and then procmail would have to try for
| another match.
| 
| (2) procmail would have to presort incoming mail to remove duplicates
| of a messages with the same sender-assigned Message-id.

... it seems you want the first arriving copy of an item addressed to list1,
list2, and list4 [and you] to be stored in folder1, folder2, and folder4 [and
your inbox], and the remaining two [or three] copies to be discarded.  I'm
not sure that's such a good idea, because the various lists may munge the
headers in different ways, and you really might not want list2's version of
a distribution in folder4.

| Thus the process would be:
| 
| remove duplicates:              M1, M2, M3, M4 --> M'
| 
| build a recipient list:         R := (L1, L3, L5, P)
| 
| find a match for each           WHILE ! empty(R)
| list item:                        consider first(R) and try to match
|                                   ...
|                                   R := rest(R)
|                                 END

Well, that can be done, but there's an easier way than bulding and then
taking apart a recipient list (replace 102400 with the size of the cache you
want to keep):

 :0h:.msgidcache.lock # lose duplicates
 | formail -D 102400 .msgidcache

 LASTFOLDER # make sure it's unset in case any `c' recipes matched earlier

 :0c:
 * test for list 1
 folder1
 :0c:
 * test for list 2
 folder2
 :0c:
 * test for list 3
 folder3
 :0c:
 * test for list 4
 folder4
 :0c: # yes, folks, I do mean a c flag here in case of a personal copy
 * test for list 5
 folder5

 :0:
 * LASTFOLDER ?? .
 {
  :0: # if to me personally as well as to a list
  $ ^TO_$LOGNAME
  $DEFAULT

  :0E
  /dev/null
 }

Of course, if the actions were to forward rather than to save, I would have
recommended Gunther's original plan to build a recipient list and to forward
to all recipients at once.

| I wonder if procmail can do that,

It can.  The fault with that approach is that it doesn't allow for proper
filing of items sent as blind carbons to a list or as direct blind carbons
to you.  That, and that if there is a direct copy to you, it will almost
always be the first one to arrive, so the copies of it in the lists' folders
will be of that version.

| and how other people deal with similar problems.

I deal with it by tolerating the duplicates.  I file mail from lists not
according to their To: or Cc: headers but by identification added by the
list software, such as X-Mailing-List: or From_ or Sender: or Resent-Sender:.
If there is a direct personal copy to me as well, it has none of those
indications of being processed by the list software, so it goes to my default
inbox, which is exactly where I want to have it.  So if something is cross-
posted to two lists where I subscribe and sent to me directly, each of the
three incoming copies is filed in is place when it reaches me.

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