Mailbox migration

April 26, 2022

Lang: cs en de es

It is not uncommon for a domain owner to decide to move mail services to another provider or simply move from one server to another typically with a different technology background. But how do you move the contents of mailboxes? The ideal is to use the IMAP protocol and some tool to do this so that each user does not have to do it manually. In this article I will introduce a tool that will perform the copying of mail and show you how to use it straight away.


You can copy files between compatible servers. This assumes, however, that someone has access to the servers. This is one possible solution if you have, for example, a Linux mail server.
If you use IMAP to access emails, then you can simply upload emails from yourself to the server. With it you can, for example, use a regular mail client to copy content from one mailserver to another. However, this is actually manual work.
For automation, you can use the ImapSync tool. Official imapsync project website.
This tool can make your work much more efficient because you can prepare everything in advance, test it and do the initial copying. Then on the day of the switch to the new server, you just need to sync the changes=copy the new emails and delete the deleted ones. Plus, you can run all this on a server that runs nonstop and on a fast network. you don't need a fast connection or a work computer on all the time.


Surprisingly, there is no installation package for my favorite server distribution Debian. So it is one of the options to install imapsync from source. The source code for imapsync is available on GitHub.
For my desktop distribution Mageia installer package exists. The easiest and most universal way to make imapsync work is to create a docker image based on the Mageia distribution and install ImapSync and everything else you need into it.

I have already prepared the definition of such a docker image. It is a dockerfile and scripts. The source codes for this The docker image with imapsync are on github.


After downloading the sources, create a docker image with the following command. And at the same time you name it imapsync:
docker build ./ -t imapsync

Imapsync usage

From a finished docker image, start a new container with the command:

docker run -v ${PWD}:/root/imapsync -it --rm imapsync /bin/bash
This will start the console and also make the data from the local directory available inside the container

Sample configuration files are also part of the prepared docker container: and input.example.csv.
Which you need to rename to and example.csv and fill in the mail accounts of the source and destination, including the password and server address. Then just run the script and it will synchronize the emails from the source server to the destination server according to your configuration.

Video tutorial

Video tutorial on how to use docker container with imapsync:

Thematic videos

Články na podobné téma

Running Microsoft SQL Server on Linux
Backup: the Proxmox Backup Server
Linux as a router and firewall
How to upload a docker image to the Docker Registry
Linux: logical volume management
Linux Software RAID
Running a web application behind a proxy
Docker multistage build
Importing Windows into Proxmox virtualization
Docker and PHP mail
Proxmox virtualization
Docker and Cron
Lenovo ThinkPad X1 Carbon: LTE modem EM7544 commissioning
Yocto Project: Build custom operating system for embedded devices
How to address poor file share performance in Docker
How to get started using Docker correctly
Installing Linux on a dedicated HPE ProLiant DL320e server
How to stress test a web application
Why use the JFS filesystem
How to boot from a 4TB drive with GTP using UEFI
Btrfs file system
Raspberry PI
WINE - running Windous programs under Linux
GNU/Linux operating system


If you are interested in receiving occasional news by email.
You can register by filling in your email news subscription.