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. As of this writing it’s version 2.231 and it can be found like this:

wget -N https://imapsync.lamiral.info/imapsync

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 Tecadmin.net

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 \
cpanminus

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 https://github.com/imapsync/imapsync.git
cd imapsync
mkdir -p dist
sudo make install

Installation done. Here are two examples:

Example 1

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 127.0.0.1 --ssl2 --user2 [email protected] --password2 'hopefully_same_secret'

Example 2

imapsync --host1 imap.source.example.com \
--user1 [email protected] \
--password1 S0urcePassw0rd \
--ssl1 \
--host2 imap.dest.example.com \
--user2 [email protected] \
--password2 Dest1nat10NPassw0rd \
--ssl2

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

References

 

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