From 582eb25eccedcdbff029947f777a111a9b7008af Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 14 Sep 1999 06:35:11 +0000 Subject: Duplicate suppression. svn path=/trunk/; revision=2553 --- NEWS | 1 + driver.c | 23 +++++++++++++++++++++++ fetchmail.h | 1 + fetchmail.man | 11 +++++++++-- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index b2fa06de..ef7f70af 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ fetchmail-5.0.8 (): * Todd Sabin's patch to accept spaces in CRAM-MD5 names. * Fix to endianness patch, by Dan Root via Lawrence Rogers. +* Suppress duplicates by message ID in multidrop mode. fetchmail-5.0.7 (Sat Aug 21 04:26:13 EDT 1999): * RPA support works again. diff --git a/driver.c b/driver.c index 444eda0e..42bfacfc 100644 --- a/driver.c +++ b/driver.c @@ -527,6 +527,29 @@ static int readheaders(int sock, /* we see an ordinary (non-header, non-message-delimiter line */ has_nuls = (linelen != strlen(line)); + /* + * When mail delivered to a multidrop mailbox on the server is + * addressed to multiple people, there will be one copy left + * in the box for each recipient. Thus, if the mail is addressed + * to N people, each recipient would get N copies. + * + * Foil this by suppressing all but one copy of a message with + * a given Message-ID. Note: This implementation only catches + * runs of successive identical messages, but that should be + * good enough. + */ + if (MULTIDROP(ctl) && !strncasecmp(line, "Message-ID:", 11)) + { + if (ctl->lastid && !strcasecmp(ctl->lastid, line)) + return(PS_REFUSED); + else + { + if (ctl->lastid) + free(ctl->lastid); + ctl->lastid = strdup(line); + } + } + /* * The University of Washington IMAP server (the reference * implementation of IMAP4 written by Mark Crispin) relies diff --git a/fetchmail.h b/fetchmail.h index 9ff6d899..c2b8b17e 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -266,6 +266,7 @@ struct query unsigned int uid; /* UID of user to deliver to */ struct idlist *skipped; /* messages skipped on the mail server */ struct idlist *oldsaved, *newsaved; + char *lastid; /* last Message-ID seen on this connection */ /* internal use -- per-message state */ int mimemsg; /* bitmask indicating MIME body-type */ diff --git a/fetchmail.man b/fetchmail.man index abf9c2d1..2c2ac746 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -870,8 +870,9 @@ code recognizes and discards the message on any of a list of responses that defaults to [571, 550, 501, 554] but can be set with the `antispam' option. This is one of the .I only -two circumstance under which fetchmail ever discards mail (the others -are the 552 and 553 errors described below). +three circumstance under which fetchmail ever discards mail (the others +are the 552 and 553 errors described below, and the suppression of +multidropped messages with a message-ID already seen). .PP If .I fetchmail @@ -1543,6 +1544,12 @@ poll mailhost.net via localhost port 1234 with proto pop3: Use the multiple-local-recipients feature with caution -- it can bite. Also note that all multidrop features are ineffective in ETRN mode. +Also, note that in multidrop mode duplicate mails are suppressed. +A piece of mail is considered duplicate if it has the same message-ID +as the message immediately preceding. Such runs of messages may +be generated when copies of a message addressed to multiple +users are delivered to a multidrop box. + .SS Header vs. Envelope addresses The fundamental problem is that by having your mailserver toss several peoples' mail in a single maildrop box, you may have thrown away -- cgit v1.2.3