40.7.1 Configuration and Use
mailsync distinguishes between the mailbox itself (the
store) and the connection between two
mailboxes (the channel). The definitions of the
stores and channels are stored in ~/.mailsync.
The following paragraphs explain a number of store examples.
A simple definition might appear as follows:
store saved-messages {
pat Mail/saved-messages
prefix Mail/
}
Mail/ is a subdirectory of the user's home
directory that contains e-mail folders, including the folder
saved-messages. If mailsync is started with
mailsync -m
saved-messages, it lists an index of all messages in
saved-messages. If the following definition is
made
store localdir {
pat Mail/*
prefix Mail/
}
the command mailsync -m
localdir lists all messages stored under
Mail/. In contrast, the command
mailsync localdir
lists the folder names. The specifications of a store on an IMAP
server appear as follows:
store imapinbox {
server {mail.edu.harvard.com/user=gulliver}
ref {mail.edu.harvard.com}
pat INBOX
}
The above example merely addresses the main folder on the IMAP
server. A store for the subfolders would appear as follows:
store imapdir {
server {mail.edu.harvard.com/user=gulliver}
ref {mail.edu.harvard.com}
pat INBOX.*
prefix INBOX.
}
If the IMAP server supports encrypted connections, the server
specification should be changed to
server {mail.edu.harvard.com/ssl/user=gulliver}
or, if the server certificate is not known, to
server {mail.edu.harvard.com/ssl/novalidate-cert/user=gulliver}
The prefix is explained later.
Now the folders under Mail/ should be
connected to the subdirectories on the IMAP server:
channel folder localdir imapdir {
msinfo .mailsync.info
}
mailsync uses the msinfo file to keep track
of the messages that have already been synchronized.
The command
mailsync folder does
the following:
-
Expands the mailbox pattern on both sides.
-
Removes the prefix from the resulting folder names.
-
Synchronizes the folders in pairs (or creates them if they
do not exist).
Accordingly, the folder INBOX.sent-mail
on the IMAP server is synchronized with the local folder
Mail/sent-mail (provided the definitions
explained above exist). The synchronization between the individual
folder is performed as follows:
-
If a message already exists on both sides, nothing happens.
-
If the message is missing on one side and is new (not listed
in the msinfo file), it is transmitted there.
-
If the message merely exists on one side and is old (already
listed in the msinfo file), it is deleted there
(because the message that had obviously existed on the other side
was deleted).
To know in advance which messages will be transmitted and
which will be deleted during a synchronization, start mailsync with
a channel and a store with
mailsync folder
localdir. This command produces a list of all messages that
are new on the local host as well as a list of all messages that
would be deleted on the IMAP side during a synchronization.
Similarly, the command
mailsync folder
imapdir produces a list of all messages that are new on the
IMAP side and a list of all messages that would be deleted on the
local host during a synchronization.
40.7.2 Possible Problems
In the event of a data loss, the safest method is to delete
the relevant channel log file msinfo.
Accordingly, all messages that only exist on one side are viewed as
new and are therefore transmitted during the next synchronization.
Only messages with a message ID are included in the
synchronization. Messages lacking a message ID are simply ignored,
which means they are not transmitted or deleted. A missing message
ID is usually caused by faulty programs when sending or writing a
message.
On certain IMAP servers, the main folder is addressed with
INBOX and subfolders are addressed with a
randomly selected name (in contrast to INBOX and INBOX.name).
Therefore, for such IMAP servers, it is not possible to specify a
pattern exclusively for the subfolders.
After the successful transmission of messages to an IMAP
server, the mailbox drivers (c-client) used by mailsync set a
special status flag. For this reason, some e-mail programs, like
mutt, are not able to recognize these messages as new. Disable the
setting of this special status flag with the option
-n.