Skip to content

Migrating mails via imapsync

Are you migrating data from Kopano Groupware?

In this case we recommend to use 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 kopano.cloud --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 may be system folders that cannot be recreated through IMAP, like the Junk Mail folder for example.
  • --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 adapted to the language of the source mailbox. To see a list of all folders in the source mailbox add --justfoldersizes to the imap command to only generate a summery in imapsync, but not do any actual mail migration.

The following additional parameters could also be 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 can lead to data loss.
  • --useuid: Uses the unique identifier (UID) of emails to match and sync messages 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 common.
  • --sep2 "/": Sets the folder hierarchy separator for the destination server. This ensures that folder structures match correctly between servers.