Migrating mails via imapsync¶
Are you migrating data from Kopano Groupware?
In this case, we recommend using our dedicated Kopano migration tool instead.
Imapsync is a popular tool to migrate mails from one IMAP server to another.
The following command can be used to migrate data from the source server (credentials specified as --host1
, --user1
and --password1
) to the destination server (credentials specified as --host2
, --user2
and --password2
):
docker run --rm --network host gilleslamiral/imapsync imapsync \
--host1 source.server.com --user1 source-user --password1 'password' \
--host2 mail.myexchange.rocks --user2 user@example.com --password2 'password' \
--no-modulesversion --noreleasecheck \
--automap --useheader message-id --addheader --syncinternaldates \
--exclude Outbox --exclude Postausgang
The following parameters are important:
--automap
: This maps "special folders" to their counterparts on the destination server. This is required as there might be system folder that cannot be recreated through IMAP. Like, for example, the Junk Mail folder.--useheader message-id
: This parameter is important when copying messages (e.g. from Kopano as otherwise rerunning imapsync will lead to duplicate mails).--exclude Outbox
: The "Outbox" is a special folder that needs to be excluded from sync.
Important
The value of --exclude Outbox
needs to be updated to be in the same language as used by the source mailbox. To see a the list of folders in the source mailbox, simply add --justfoldersizes
to the imap command, to only generate a summary in imapsync. This will not complete any migration.
The following additional parameters could be added if useful:
--delete2
: Deletes messages on the destination server (--host2), that no longer exist on the source server (--host1). Be careful with this option as it could lead to data loss.--useuid
: Uses the unique identifier (UID) of emails to match and sync messages. This could be used, instead of relying on headers, reducing duplication issues.--sep1 "/"
: Sets the folder hierarchy separator for the source server. The default separator varies between servers, but/
is the most common.--sep2 "/"
: Sets the folder hierarchy separator for the destination server. This ensures that the folder hierarchy is upheld between servers.