How to Migrate Mails with IMAP Sync on CentOS 8 / Ubuntu 20.04

Migrate Mails with IMAP Sync

imapsync is an IMAP transfer tool and is used to migrate the mails from one IMAP server to another IMAP server. imapsync is a Linux package that can be downloaded from the repository on CentOS. But to download on Ubuntu distribution we need to use git repository. In this tutorial, we will learn how to migrate Mails and use the IMAP Sync to transfer the mails.

Let’s install packages on both CentOS and Ubuntu one by one. Then we will understand how to use the command. Because installation is different for both OS, but functionality is the same on both.

Read Also: How to Install and Use PHP Composer on CentOS 7 and 8

Install Imapsync on CentOS 7 / 8

  • We need to install EPEL package repository. Imapsync package is available under the EPEL package repository.
sudo yum install epel-release
  • Install Imapsync package
sudo yum install imapsync

Let’s Install Imapsync on Ubuntu 16.04 / 20.04

  • To Install Dependencies with the following command
sudo apt-get install libauthen-ntlm-perl libclass-load-perl libcrypt-ssleay-perl libdata-uniqid-perl libdigest-hmac-perl libdist-checkconflicts-perl libfile-copy-recursive-perl libio-compress-perl libio-socket-inet6-perl libio-socket-ssl-perl libio-tee-perl libmail-imapclient-perl libmodule-scandeps-perl libnet-dbus-perl libnet-ssleay-perl libpar-packer-perl libreadonly-perl libregexp-common-perl libsys-meminfo-perl libterm-readkey-perl libtest-fatal-perl libtest-mock-guard-perl libtest-mockobject-perl libtest-pod-perl libtest-requires-perl libtest-simple-perl libunicode-string-perl liburi-perl libtest-nowarnings-perl libtest-deep-perl libtest-warn-perl make cpanminus
  • Download Imapsync package from git.
git clone
  • We need to compile imapsync first, so we need to run below command.
cd imapsync
mkdir dist
sudo make install
  • Check the Imapsync Version
imapsync -v

Transfer Emails with IMAP

To transfer the mail follow the below command

imapsync --host1 Source_Ip --user1  Source_Email  --password1 Source_Email_Password --host2 Destination_Ip --user2 Destination_Email   --password2 Destination_Email_Password

--host1 – Put the Source server IP address or

--user1 – Input the Source Email Address.

--password1 – Enter the Source email address password.

--host2 – Mention the Destination’s server IP address or

--user2 – Put the Destination Email Address.

--password2 – Mention the Destination email address password.

For Example:-

imapsync --host1 --user1 [email protected]  --password1 [email protected]#S5m --host2 192.122.585.125 --user2 [email protected]   --password2 [email protected]!dess*n

In the above command –host1 ( represents the source server and –host2 (192.122.585.125) represents the destination server. The –user1 ([email protected]) represents the source mail account and –user2 ([email protected]) represents the destination mail account. The –password1 ([email protected]#S5m) represents the password of the source mail account and –password2 ([email protected]!dess*n) represents the password of the destination mail account.


In this, we have learned how to install and Migrate Mails with the IMAP Sync server to another IMAP server. We need this tool when someone wants to migrate the entire mailbox to a new server from his old server.

If you guys have any queries related to this tutorial, let me know in the comments.