Snappy

Helpdesk Support

Official Supportmonk Company Blog!

Syncing your mailbox folders using ImapSync

February 22, 2018 , 9:24 pm


The imapsync  is a handy tool we can use to sync our inbox folders.
The uniqueness of this tool is that it can sync folders between two imap servers directly without any backup/restore or intermediate mail clients.

Installing ImapSync

For Fedora & Centos distros,

sudo yum install epel-release
sudo yum install imapsync

For Ubuntu

For ubuntu unfortunately the repository is not available and you have to type the following commands

sudo apt-get install makepasswd rcs perl-doc libio-tee-perl git libmail-imapclient-perl libdigest-md5-file-perl libterm-readkey-perl libfile-copy-recursive-perl build-essential make automake libunicode-string-perl libauthen-ntlm-perl libcrypt-ssleay-perl libdigest-hmac-perl libfile-copy-recursive-perl libio-compress-perl libio-socket-inet6-perl libio-socket-ssl-perl libio-tee-perl libmodule-scandeps-perl libnet-ssleay-perl libpar-packer-perl libreadonly-perl libterm-readkey-perl libtest-pod-perl libtest-simple-perl libunicode-string-perl liburi-perl cpanminus

#Install modules from CPAN

sudo cpanm JSON::WebToken Test::MockObject Unicode::String Data::Uniqid

#Get the imapsync from  git repository

git clone git://github.com/imapsync/imapsync.git

 

#Build and install

cd imapsync
mkdir dist
sudo make install

Transfer emails wih ImapSync

You have to ensure that both imap servers are up and running.

After that you can ensure the following command syntax

imapsync --host1 hostname1 --port1 port# --user1 #1 --domain1 fully.qualified.domain #1 --ssl1 --host2 hostname2 --port2 port# --user2 userid#2 --domain2 fully.qualified.domain #2 --ssl2

 

e.g.;

For syncing mails from imap.imapserver.net to localhost,

imapsync --host1 imap.imapserver.net --user1 [email protected] --password1 4HrJazz1! --host2 localhost --user2 [email protected] --password2 4DrJazz1!

 

If you don’t want to give passwords directly in terminal which will be shown in the ps command,
it’s better to create two files (/etc/secret1 and /etc/secret2 in this example) that contain the passwords , do a chmod 600 on these files, and use the –passfile1 and –passfile2 switches.

echo “4HrJazz1!” > /etc/secret1
echo “4HrJazz1!” > /etc/secret2
chmod 600 /etc/secret1
chmod 600 /etc/secret2

Now we can do the migration with this simple command:

imapsync --host1 imap.imapserver.net --user1 [email protected] --passfile1 /etc/secret2 --host2 localhost --user2 [email protected] --passfile2 /etc/secret2

 

Outsourced Customer Support