• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

acinclude/H03-May-2022-642622

debian/H30-Jun-2004-376251

doc/H03-May-2022-444376

src/H30-Jun-2004-3,8882,633

AUTHORSH A D24-Jan-200311 21

COPYINGH A D22-Jan-2003652 1913

Makefile.amH A D14-Jun-2004621 179

Makefile.inH A D30-Jun-200418.4 KiB580490

NEWSH A D30-Jun-20046.3 KiB182139

READMEH A D18-Jun-200417.9 KiB525369

THANKSH A D11-May-20041.2 KiB2825

TODOH A D09-Jun-20042.7 KiB8257

aclocal.m4H A D30-Jun-200449.2 KiB1,5081,354

autogen.shH A D01-Jun-2004255 86

config.h.inH A D30-Jun-20042.6 KiB10067

configureH A D30-Jun-2004218.3 KiB7,5196,241

configure.acH A D03-May-2022776 4534

depcompH A D16-Dec-200311.8 KiB424278

install-shH A D16-Dec-20036.2 KiB270153

missingH A D16-Dec-200310 KiB337263

mkinstalldirsH A D16-Dec-20031.8 KiB10072

README

1Mailsync
2--------
3
41.   Compiling mailsync
52.   Configuring mailsync
62.1     Mailbox specification
72.2     Stores
82.3     Channels
93.   How does mailsync work?
104.   Running mailsync
114.1     Verbosity
124.2     Various messages from mailsync
135.   Limitations
145.1     Problems with concurrent mailbox access
155.2     Problems wit "New" messages (Mutt)
165.3     Empty Message-ID headers
176.   More about the algorithm
186.1     Message id algorithms
197.   History
208.   Further reading
219.   Support and homepage
2210.  Author, disclaimer, etc.
23
24
25
261. Compiling mailsync
27---------------------
28
29Mailsync has been built on Linux, FreeBSD and on SGI-Irix 6.5. With a
30little coaxing, though, it should compile on any unix-like system on
31which c-client compiles.  On a non-unix-like system, you may have to
32come up with alternatives to a few functions like stat() and getenv().
33
341. Download, unpack, and compile the c-client from
35   ftp://ftp.cac.washington.edu/imap.  Currently I'm using
36   imap-2002.RC8, which allows linking from a C++ program.  If you
37   already have an older version of c-client installed, you can still
38   link it to Mailsync.  Just get c-client.h from either the latest IMAP
39   distribution or from http://mailsync.sourceforge.net.
40
41If you're building mailsync from CVS you'll need an automake version later
42than 1.6. The following should do the deal:
43
442. ./autogen.sh
45
46After that the build procedure is the same as building from a released
47source package:
48
492. ./configure && make && make install
50
51
52
532. Configuring mailsync
54-----------------------
55
56To use mailsync, you first have to make a configuration file, which by
57default is `$HOME/.mailsync'.  The config file specifies two kinds of
58things: "stores" and "channels".
59
60Lines in the mailsync configuration file starting with a `#' are
61regarded as comments and are being ignored.
62
63A "store" describes a mailbox and which parts of that mailbox you want
64to have synchronized.  A channel is a pair of stores which you want to
65get synchronized along with a file where mailsync can save
66synchronization info.
67
68Additionaly mailsync initializes and reads in c-client configuration to
69fine tune it's behaveour. You will very likely not need to bother about
70that. Before you tinker with it make sure to read the imaprc.txt
71documentation file from c-client.
72
73
742.1 Mailbox specification
75-------------------------
76
77Mailsync uses the c-client library for manipulation of mailboxes.  Please
78have a look at the c-client library documentation for details of the
79format of a mailbox specification.  Especially have a look at
80docs/naming.txt and docs/drivers.txt from it's documentation.
81
82Briefly, a mailbox specification looks like this:
83
84 {imap.unc.edu/user=culver}           refers to INBOX by default
85 {imap.unc.edu/user=culver}INBOX.foo  a mailbox on a Cyrus server
86 {imap.unc.edu/user=culver}foo        a mailbox on a UW or Netscape server
87 mbox                                 the file $HOME/mbox
88 Mail/foo                             a mailbox in $HOME/Mail
89 /tmp/foo                             some other file
90
91
92
932.2 Stores
94----------
95
96A store is a collection of mail folders.  Exactly what kind of
97collection you can use depends on your IMAP server, but one thing that
98always works is a bunch of folders in a single directory.
99Unfortunately there is no general, concise way to specify even this
100kind of store.  I have settled on a fairly general but redundant
101method.
102
103Here are examples of store specifiers that work with some servers I
104have access to.
105
106store cyrus {
107	server	{imap.unc.edu/user=culver}
108	ref	{imap.unc.edu}
109	pat	INBOX.sync.%
110	prefix	INBOX.sync.
111	passwd  secret
112}
113store netscape-or-uw {
114	server	{imap.cs.unc.edu/user=culver}
115	ref	{imap.cs.unc.edu}
116	pat	sync/%
117	prefix	sync/
118}
119store localdirectory {
120	pat	Mail/%
121	prefix	Mail/
122}
123
124To test a store specification, put it in your .mailsync and run
125
126  mailsync <storename>
127
128Mailsync will list the mailboxes it thinks are in the store.  (In this
129mode, it will not touch anything or even open the mailboxes.)  The
130names it returns should be stripped of any store-specific information.
131
132`Pat' describes the pattern of the boxes you want to synchronize.  It
133matches names exactly except for:
134
135* the delimiter character which is used to delimit hierarchies (folders)
136  in your mailbox and which depends on the mailstore you use (unix
137  filesystems use `/', Cyrus, UW and Netscape use `.').
138
139* `%' is a globing operator.  It will match all the items in a hierarchy
140  (folder) but it will not descend down the hierarchy (into folders).
141
142* `*' acts like `%' but descends into the hierarchy.  Be careful with `*'
143  as it can take a lot of time to traverse a deep hierarchy.
144
145If you omit the `prefix' specification, you will see full mailbox
146names.  Whatever you specify in `prefix' is stripped off of these
147names to form what I shall call a "boxname".
148
149Two mailboxes on different stores will be synchronized if and only if
150they have the same "boxname".  Finally, the full c-client name is formed
151by <server><prefix><boxname>.
152
153`passwd' is the password to use when accessing the box. If you omit it and
154the store will require a password then mailsync will ask you for it.
155
156If you want to use MH files, or some other format, you should check
157out the "docs/" directory in the imap distribution, particularly
158naming.txt, drivers.txt, and formats.txt.
159
160
161
1622.3 Channels
163------------
164
165A channel just specifies two stores that are to be synchronized, and
166one c-client mailbox `msinfo' which is used by mailsync to remember
167what messages it has seen (it stores there sets of message-ids in
168between runs).  Any c-client mailbox specification is fine.  If one
169or both of the stores is a local file, then you might as well use a
170local file for `msinfo':
171
172channel local-cyrus localdirectory cyrus {
173	msinfo	.msinfo
174}
175
176The message-id list is kept as a message in the mailbox, with the
177channel tag ("local-cyrus") as the subject.  So you can use the same
178`msinfo' file for many channels, as long as the channels have
179different names.
180
181If, on the other hand, both stores are on remote imap servers, you may
182consider putting `msinfo' on one or on the other server:
183
184channel uw-cyrus netscape-or-uw cyrus {
185	msinfo	{imap.cs.unc.edu/user=culver}msinfo
186	passwd secret
187}
188
189The `msinfo' mailbox stores a bunch of message-ids in a mail message.
190The message is formed without a message-id, so you can even put the
191`msinfo' inside the store if you like, and mailsync will not copy or
192delete the `msinfo' message.  (This may change, though.  Better to
193keep it separate from the stores.)
194
195As for stores `passwd' can be omitted and in case it's required mailsync
196will ask for it.
197
198In the channel specification you can optionally set message size limit.
199Messages with size exceeding the limit (in bytes) will be skipped when
200synchronizing:
201
202channel uw-cyrus netscape-or-uw cyrus {
203	msinfo {imap.cs.unc.edu/user=culver}msinfo
204	passwd secret
205	sizelimit 81920
206}
207
208The example above will not synchronize messages bigger than 80k.
209
210
2113. How does mailsync work?
212--------------------------
213
214First, it loads the state of the store at the last sync.
215
216If a "lasttime" mailbox doesn't exist, it is assumed empty.  This is
217the right thing to do.
218
219Then it iterates through every mailbox on either store.  In each
220mailbox, it applies the following 3-way diff algorithm.
221
222  If a message exists on both stores, it is left alone.
223
224  If a message exists on one store but not the other, and it is a
225  "new" message (it's not recorded in `msinfo'), it is copied to the
226  other store.
227
228  If a message exists on one store but not the other, and it is an
229  "old" message (it was recorded in `msinfo' at last synchronization),
230  it is assumed that the message was deliberately deleted from one
231  store, and is removed from the other.
232
233Finally, it saves the set of remaining messages to the `msinfo' file.
234
235
236
2374. Running mailsync
238-------------------
239
240There are three modes.
241
242
243"Sync" mode:
244
245    mailsync [options] <channel>
246
247Synchronizes the two stores specified by the channel,
248doing a 3-way diff with the message-ids stashed in the channel's
249msinfo box.
250
251
252"List" mode:
253
254    mailsync [options] <store>
255
256Simply list the boxnames specified by the given store.  Don't change
257or write anything.  Useful when writing the .mailsync config file.
258
259
260"Diff" mode:
261
262    mailsync [options] <channel> <store>
263 or mailsync [options] <store> <channel>
264
265Compare the messages in the store to the information in the channel's
266msinfo file.  This mode does not disturb any mail.  This is useful if,
267for instance, <store> is local, <channel>'s msinfo is a local file,
268but <channel>'s other store is remote and you're not dialed up.
269Mailsync will tell you how many new messages and deletions would be
270propagated away from <store> through <channel>.  It also reports
271duplicate messages (without deleting them).
272
273The options change from time to time, and are described if you just
274type "mailsync".
275
276The `-D' option deletes empty mailboxes after synchronizing (and works
277only in "Sync" mode).  Mailsync doesn't differentiate between empty
278and missing mailboxes.  Suppose you delete a mailbox on store A but
279not on store B.  Without `-D', mailsync will delete all messages on B,
280but it will also resurrect the mailbox on A.  With `-D', both
281mailboxes will be deleted.  Your choice.
282
283
284
2854.1 Verbosity
286-------------
287
288Mailsync knowns a series of log_levels. If you encounter problem with
289mailsync you should enable those to let mailsync tell you more about
290what's going on. Run:
291
292    mailsync --help
293
294to see what logging options mailsync offers. The different log levels
295are described in the c-client documentation "internal.txt" under mm_log.
296
297
298
2994.2 Various messages from mailsync
300----------------------------------
301
302When running mailsync with the "-m" you'll can see what messages mailsync
303is copying forth and back. Below is an example session with an explanation
304of the actions that mailsync is taking:
305
306    $ mailsync -vw -m inbox
307    Synchronizing stores "local-inbox" <-> "remote-inbox"...
308    Authorizing against {[192.168.1.2]/imap}
309
310     *** INBOX ***
311
312      deleted    >  Wed Jun  9 tony kwami             FROM MR TONY KWAMI.
313      duplicate     Wed Jun  9 Some Hero              Re: comment
314    1 duplicate for deletion in INBOX/remote-inbox
315    Authorizing against {[192.168.1.2]/imap}
316      ign. del   <  Wed Jun  9 Mail Delivery System   Mail failure - no recipient a
317      copied     <- Wed Jun  9 Debian Bug Tracking Sy Bug#253290 acknowledged by de
318
319    1 copied remote-inbox->local-inbox.
320    1 deleted on remote-inbox.
321    69 messages remain in INBOX
322    Expunged 2 mail(s) in store remote-inbox
323
324Above you can see that:
325
326* a spam from some "tony kwami" was deleted on the remote mailbox, since I have
327  deleted it locally
328
329* "Some Hero" sent me the same message twice - probably he sent it to me
330   and to some mailing list in the "Cc:". Since I'm using msg-id algorithm,
331   the duplicate is detected and automatically deleted.
332
333* copying a message from a mail daemon was not done, since it is marked as
334  deleted in the remote mailbox and mailsync by default doesn't copy
335  deleted mails
336
337* a mail from the Debian Bug Tracking System was copyied to the local mailbox.
338
339
340
3415. Limitations
342--------------
343
344Mailsync assumes that the message-id is a global unique identifier.
345If it isn't, then it won't work.  Here are some situations where the
346message-id assumption doesn't quite hold.
347
3481. Two different messages in the same mailbox with the same
349   message-id.  Mailsync will delete the one that comes later in the
350   mailbox.
351
3522. Two different messages in different mailboxes with the same
353   message-id.  Mailsync will never notice; everything works.
354
3553. A message with no message-id.  Mailsync prints a warning and leaves
356   the message alone.  It will never be copied to any other store, nor
357   deleted for any reason.
358
3594. A message that resides on both stores which is then edited on one
360   store.  The edit will not be propagated to the other store.  A
361   workaround is to edit the message-id when you edit the message.
362   This will be interpreted by mailsync as a delete and a new message,
363   and everything will work.
364
365Another limitation is that when a message is moved from one mailbox to
366another, mailsync interprets this by a deletion from one box and a new
367message in the other.  This simplifies the algorithm a lot, but wastes
368some network bandwidth if you move large messages around between
369syncs.  Workaround: try to put large messages in their final resting
370place before you run mailsync.
371
372
373
3745.1 Problems with concurrent mailbox access
375-------------------------------------------
376
377Mailsync is not coded with concurrent access in mind. It shouldn't
378break in a horrible way, since it tries to double-check before it
379deletes something, but it is not really fit for the task either.
380Efforts to make it concurrency capable are certainly appreciated.
381
382
383
3845.2 Problems wit "New" messages (Mutt)
385--------------------------------------
386
387The mail header line "Status: O" is interpreted differently depending
388on which mail client you're using. Pine and it's mailbox manipulation
389library c-client assume, that a new message is new as long as you
390have not read it.
391
392Mutt and possibly some other clients interpet only a mail with
393"Status: " as unseen. If you want mutt to see all "new" messages as
394"new", then you must use the "-n" (do not delete messages) option of
395mailsync. This will have the effect of not deleting any messages, not
396even duplicates on either store you're synchronzing.
397
398Explanation:
399
400c-client's author says the following:
401
402"The definition of "Recent" [that is "Status: " - tpo] is that the
403 message has arrived since the last time the mailbox was opened
404 readwrite."
405
406Strangely enough appending new messages to a mailbox can be done without
407opening a mailbox read-write. However any other operation that change
408anything in a mailbox such as tagging a message as deleted or expunging
409old messages needs to be done in read-write mode. As soon as that happens
410*all* messages will be tagged with "Status: O" and hence loose their
411"Recent" status. That means that if we want to be able to maintain that
412status, we are not allowed to tag messages as deleted, to expunge messages
413or similar.
414
415
416
4175.3 Empty Message-ID headers
418----------------------------
419
420Some mail software produces messages with no or empty Message-ID headers in
421particular for draft or unsent messages and in particular Microsoft Outlook.
422That means that mailsync will not be able to uniquely identify such a message
423using the Message-ID header. If you need to synchronize such messages you
424should use the md5 message id algorithm. You can achieve this by passing
425"-t md5" to mailsync.
426
427Mailsync deletes duplicate messages by default - assuming that they're the
428same. However if it finds multiple messages with empty Message-IDs it will
429display the message:
430
431        "Not deleting duplicate message with empty Message-ID - see README"
432
433and leave that message alone, supposing that this is just another email
434produced by weird software.
435
436
437
4386. More about the algorithm
439---------------------------
440
441The sync operation is symmetric---it doesn't matter which store you
442specify first.  This is fundamentally different from the IMAP
443disconnected-mode mail reading model, where there is a primary store,
444and a client is responsible for synchronizing its local copy with the
445primary store.  There is no limitation to the number of stores you
446sync with each other.  Think of the stores as nodes of a graph, and
447put links between the stores you want to sync between.  If there are
448no cycles, then everything will work.  If there are cycles, some weird
449things can happen that I haven't totally worked out yet: I think that
450a message could be passed back as a new message to a store which
451deleted it, for example.
452
453Since both stores can be local, and in different formats, you can also
454use mailsync as a method for keeping all of your messages accessible
455by two MUAs, even if neither is IMAP-aware.  So mailsync could help
456you transition between MUAs.
457
458
459
4606.1 Message id algorithms
461-------------------------
462By default mailsync uses the Message-ID header to uniquely identify email
463messages. In case this is not possible (see 5.2) mailsync can use a md5
464hash of a number of mailheaders (defined in msgid.c) to identify a message.
465
466
467
4687. History
469----------
470
471Mailsync-1 was a bunch of shell scripts.  Mail was parsed using awk
472and transferred using ftp.
473
474Mailsync-2 was a Java program that suffered from the Second System
475Effect.  It was never completed.
476
477Mailsync-3 was written in C over the c-client library.  I used it for
478over a year without any surprises.
479
480Mailsync-4 is a C++ program based on mailsync-3.  I was able to remove
481a lot of cruft and make things a little more sensible, safe, and
482efficient.
483
484Mailsync-4.2 and on has seen extended documentation and some
485reengineering efforts to make it easier to read, patch and understand.
486
487
488
4898. Further reading
490------------------
491
492RFC 2076 - Common Internet Message Headers
493RFC 1176 - IMAP v2
494RFC 1203 - IMAP v3
495RFC 2060 - Internet Message Access Protocol - Version 4rev1
496         - being updated: http://www.imc.org/draft-crispin-imapv
497RFC 2342 - NAMESPACES (discovery of where my "*&/%* mailboxes are)
498http://www.iana.org/assignments/imap4-capabilities
499http://www.ics.uci.edu/~mh/book/mh/tocs/jump.htm
500
501
5029. Support, development, new versions and homepage
503--------------------------------------------------
504
505Mailsync's homepage is at http://sourceforge.net/projects/mailsync.
506There's also a CVS repository there in which mailsync development
507happens. Announcements about new versions are usually posted on
508http://freshmeat.net. If you need help or have a patch or
509suggestion to contribute then subscribe to the mailsync mailing
510list and post it there. Instructions on how to do so can be found
511on mailsyncs homepage. Tomas Pospisek will also provide commercial
512support if needed (see below).
513
514
515
51610. Author, disclaimer, etc.
517---------------------------
518
519Mailsync's author is Tim Culver <fullcity@sourceforge.net>.
520Since version 4.2 Tomas Pospisek <tpo_deb@sourcepole.ch> maintains
521the code.  Mailsync is copylefted under the GNU General Public
522License: http://www.gnu.org/copyleft/gpl.html
523Linking with openssl is explicitly permitted!
524
525