Re: Gnome Mailing List



Florian Hars writes:
 > 
 > 
 > On 21 Jan 1998, Alan Shutko wrote:
 > > That's why mail has message-ids.  So you don't have to see multiple
 > > copies of mail.
 > 
 > Email has no message ids. RTFRFC.

That's why you do a checksum on the email, and discard subsequent
matching copies.  There's a flaw in the the SMTP protocol which is not
widely known.  If you send the DATA part of a message, and do not get
the acceptance confirmation, you have to re-send the mail, even though
the recipient may have delivered it (you can't tell).  So an implicit
part of SMTP is discarding duplicate copies (not that anyone actually
does it).  Here's a filter for qmail (http://www.qmail.org) which
closes this hole in SMTP, and incidentally, also eliminates duplicate
copies sent directly and via a mailing list.
-russ


#! /usr/bin/perl
# Call from a .qmail file as follows:
#  |bin/eliminate-dups Mailbox

$hashname = shift;

use MD5;
$md5 = new MD5;

$loose = 1;			# loose matching if set.

while(<>) {
    last if /^$/;
    next if $ignore_continue && /^\s/;
    $ignore_continue = 0;
    if (/^received:/i) {
	$ignore_continue = 1;
	next;
    }
    if (!$loose) {
	$headers .= $_;
	next;
    }
    if ($keep_continue && /^\s/) {
	$headers .= $_;
	next;
    }
    $keep_continue = 0;
    if (m/^(from|message-id|date):/i) {
	$headers .= $_;
	$keep_continue = 1;
	next;
    }
    next;
}

$md5->add($headers);
$md5->addfile(STDIN);
$hash = $md5->hexdigest;
print "$headersOur hash:$hash\n";

open(HASH, "<$hashname.newer");
flock(HASH, 2);
while(<HASH>) { chomp; exit 99 if $_ eq $hash; }
open(HASH, "<$hashname.older") || die "$0: Cannot open $hashname.older";
while(<HASH>) { chomp; exit 99 if $_ eq $hash; }

# roll the files once a week.
if (-M "$hashname.older" > 7) {
	rename("$hashname.newer", "$hashname.older") || die "$0: Unable to move newer to older";
}

# add the hash to the "received messages" list.
open(HASH, ">>$hashname.newer") || die "$0: Cannot append to $hashname.newer";
print HASH "$hash\n";
close(HASH);

print "Original message";
exit 0;

-- 
-russ <nelson@crynwr.com>  http://www.crynwr.com/~nelson
Crynwr Software supports freed software | PGPok |   Freedom is the primary
521 Pleasant Valley Rd. | +1 315 268 1925 voice |   cause of Peace, Love,
Potsdam, NY 13676-3213  | +1 315 268 9201 FAX   |   Truth and Justice.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]