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:
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'
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.