1 ================================================================================
3 Duplicate Mail Checker @VERSION@
5 (c) 2006 Martin Mares <mj@ucw.cz>
7 ================================================================================
9 This package tries to solve two problems which were plaguing my mail-box for
12 (1) In many cases, a single message arrives in several copies through different
13 paths. The copies usually share a single Message-ID, so I decided to scan
14 incoming mail for duplicate Message-ID's (for this purpose, I am willing
15 to believe that SHA-1 is a perfect hash function).
17 (2) Copies of messages originated by me frequently loop back to me. This could
18 be handled by recording Message-ID's of outgoing mail, thus reducing it
19 to the previous problem, but unfortunately this is not applicable to my
20 situation as I send mail from multiple machines (not all of them on-line
21 all the time). However, there is an easier solution: generate special
22 Message-ID's for all my outgoing mail, so it can be easily recognized.
23 (It's tempting to use the From field for such purposes, but that has
24 its own problems -- for example, I want to exclude all mail generated
25 by scripts and sent through other ways than my MUA, since such mail is
26 not recorded to the outbox when sending.)
28 For this purpose, I use Message-ID: <USER+md-YYYYMMDD.HHMMSS.PID.HOST@DOMAIN>,
29 where USER@DOMAIN is my mail address and HOST is the machine I've sent the mail
30 from (to avoid potential duplicates when sending from multiple machines).
32 So I have written the `mdup' utility which receives mail headers on its standard
33 input, parses them, records a SHA-1 hash of the Message-ID in a database and
34 prints a verdict to the standard output:
36 DUP Message-ID already known
37 LOCAL Message-ID recognized as originated by me
38 OK Message-ID not recognized
39 NO ID The message has no ID
40 ERROR Some other error occured
42 (things like the USER and DOMAIN for detection of local mail or lifetime of all
43 database records get passed as command-line options).
45 This can be easily used in procmail rules:
47 DUPS=`bin/mdup -lmj@ucw.cz`
57 The only remaining problem is how to set the Message-ID for outgoing mail.
58 I have written a sendmail wrapper (smail.c) for this purpose, but then I
59 realized that this way the Message-ID's don't get recorded properly in the
60 sent mail folder, breaking all threading. However, if you use Mutt, there
61 is a neat (but a little devilish) trick how to generate Message-ID's using
62 just the Mutt's configuration language:
64 send-hook .* my_hdr Message-Id: <USER+md-\`date -u '+%Y%m%d.%H%M%S.$$.$HOSTNAME'\`@DOMAIN>
66 (Note the backslashes -- they cause the backticks to be interpolated when the
67 hook gets executed instead of when it gets parsed.)
69 Please send all bug reports and suggestions to mj@ucw.cz.
76 This program can be distributed and used according to the terms of the
77 GNU General Public License version 2 or newer.
81 `mdup' assumes that the ID hash database (by default located in ~/.mdup.db)
82 can be locked by flock(), so if your home directory is shared over NFS,
83 strange things might (and probably will) happen. Better don't do that.