How to install and use IMAPSYNC on Ubuntu

IMAPSYNC is an incredible utility to migrate email accounts between different servers. It just works. One important aspect is to always try and use the latest version.

Problem is the installation is slightly more cumbersome than usual, and the syntax for the uninitiated rather intense. The essence of the complication is that you need quite a bit Perl libraries to make it work.

This article aims to address these two issues.

Let’s kick of with the installation. There’s no official guide except an INSTALL.Ubuntu.txt file on their Github repo. This appears to be outdated since when running the final make install command it actually already copies the binary to the correct place. So our reduced instruction set combines what we see on the Github repo with a beautiful article from

Please note the elaborate apt-get command below actually needs to be used as is. All those backslashes are natural bash command line breaks and included to nicely split the screen per library.

sudo apt-get install \
libauthen-ntlm-perl \
libclass-load-perl \
libcrypt-ssleay-perl \
libdata-uniqid-perl \
libdigest-hmac-perl \
libdist-checkconflicts-perl \
libencode-imaputf7-perl \
libfile-copy-recursive-perl \
libfile-tail-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 \

Next we install quite a few Perl libraries

sudo cpanm Crypt::OpenSSL::RSA Crypt::OpenSSL::Random --force
sudo cpanm Mail::IMAPClient JSON::WebToken Test::MockObject 
sudo cpanm Unicode::String Data::Uniqid

Please note the --force If you get errors on that line, run it without --force because there is a good chance the library is already installed first time around in spite of an error. The bottom line is if you get an error, use without --force or just continue.

Our last few steps download IMAPSYNC from Github, and compiles it.

git clone
cd imapsync
mkdir -p dist
sudo make install

Installation done.

Errors (2024) – Ubuntu 22.04

Failure: Not found Perl module CGI

What you have to do before using imapsync:
Install Perl module CGI

make: *** [Makefile:96: testp] Error 1

sudo cpanm CGI

Example 1

Here are two examples:

Please note in this case the IMAPSYNC command is run on the destination host and data pulled from the source host (a.b.c.d).

imapsync --dry --skipemptyfolders --host1 a.b.c.d --user1 [email protected] --password1 'secret' --host2 --ssl2 --user2 [email protected] --password2 'hopefully_same_secret'

Example 2

imapsync --host1 \
--user1 [email protected] \
--password1 S0urcePassw0rd \
--ssl1 \
--host2 \
--user2 [email protected] \
--password2 Dest1nat10NPassw0rd \

If that’s a bit baffling and cumbersome, use our easy peasy spreadsheet which allows you to generate these commands for a number of users at once by only filling in the usernames and passwords.

See also



Share this article

2 thoughts on “How to install and use IMAPSYNC on Ubuntu”

  1. This is useless. You fail to mention that gcc and libssl-dev must be installed, which you wouldn’t expect to find on a server. That’s why you’re getting errors around the ‘–force’ step; you can’t “just continue”.

    1. Eugène van der Merwe

      Hi! Thanks so much for the feedback. I can genuinely say that I have never had to install GCC and libssl-dev but will try to simulate the environment from a plain server-only install of Ubuntu which is the primary distribution that I work with.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top