]> mj.ucw.cz Git - maildups.git/blob - README
Teach mparse to handle maildirs
[maildups.git] / README
1 ================================================================================
2
3                            Duplicate Mail Checker @VERSION@
4
5                        (c) 2006 Martin Mares <mj@ucw.cz>
6
7 ================================================================================
8
9 This package tries to solve two problems which were plaguing my mail-box for
10 a long time:
11
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).
16
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.)
27
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).
31
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:
35
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
41
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).
44
45 This can be easily used in procmail rules:
46
47         DUPS=`bin/mdup -lmj@ucw.cz`
48
49         :0
50         * DUPS ?? LOCAL
51         Mail/looped_back
52
53         :0
54         * DUPS ?? DUP
55         Mail/duplicates
56
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:
63
64 send-hook .* my_hdr Message-Id: <USER+md-\`date -u '+%Y%m%d.%H%M%S.$$.$HOSTNAME'\`@DOMAIN>
65
66 (Note the backslashes -- they cause the backticks to be interpolated when the
67 hook gets executed instead of when it gets parsed.)
68
69 Please send all bug reports and suggestions to mj@ucw.cz.
70
71                                 Have fun
72                                                         Martin
73
74 LICENSE
75 ~~~~~~~
76 This program can be distributed and used according to the terms of the
77 GNU General Public License version 2 or newer.
78
79 CAVEATS
80 ~~~~~~~
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.