Sometimes there is a task to transfer mailboxes to another server. With a large number of letters and subfolders, there is an imapsync utility. You specify the parameters of the current mailbox and the parameters of the new mailbox, after which it will count all letters and folders and start transferring letters. In our example, the installation takes place on Debian 11.
1. Installing required packages
apt install libauthen-ntlm-perl libcgi-pm-perl libcrypt-openssl-rsa-perl libdata-uniqid-perl libencode-imaputf7-perl libfile-copy-recursive-perl libfile-tail-perl libio-socket-inet6-perl libio-socket-ssl-perl libio-tee-perl libhtml-parser-perl libjson-webtoken-perl libmail-imapclient-perl libparse-recdescent-perl libmodule-scandeps-perl libreadonly-perl libregexp-common-perl libsys-meminfo-perl libterm-readkey-perl libtest-mockobject-perl libtest-pod-perl libunicode-string-perl liburi-perl libwww-perl libtest-nowarnings-perl libtest-deep-perl libtest-warn-perl libdist-checkconflicts-perl libpar-packer-perl libtest-fatal-perl libtest-modern-perl libtest-requires-perl libtest-mock-guard-perl libproc-processtable-perl make time cpanminus git
apt-get install apt-file -y
apt-file update
2. Installing imapsync
cd /root
git clone https://github.com/imapsync/imapsync.git
cd imapsync/
make
make install
3. Let's check the utility:
imapsync --testslive
An example of a working command for moving a mailbox including all folders and letters to a new server:
imapsync --host1 --user1 --password1 --host2 --user2 --password2 --automap --ssl2 --regextrans2 "s,/,X,g"
The command is supposed to run on a new mail server, so the second server is localhost. Upon completion of the transfer of all data, a report will be displayed on the number of transferred folders and letters. It also assumes that both servers have a certificate, as indicated by the --ssl2 option.