

How to Migrate Mailboxes Easily With Imapsync on Ubuntu
source link: https://www.vultr.com/docs/how-to-migrate-mailboxes-easily-with-imapsync-on-ubuntu-16-04-lts
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Using a Different System?
While migrating websites is usually not a problem, sometimes it's more difficult to migrate email boxes. This is especially the case when two servers do not use the same software. Fortunately, to simplify this step, there are many tools, including Imapsync, which we will talk about today.
The Imapsync tool makes it possible to synchronize mailboxes using the IMAP protocol. This will only work if you also use IMAP to retrieve your emails or if you do not erase your emails from the server with the POP protocol.
Requirements
- A sudo user.
- A Vultr Ubuntu server instance.
These instructions have been tested on Ubuntu versions 16.04 and 20.04.
Before installing any packages on the Ubuntu server instance, update the system.
$ sudo apt-get update
$ sudo apt-get -y upgrade
Installation
First, you need to install the necessary prerequisites to run Imapsync.
$ 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
If you want to update the Perl module Mail::IMAPClient, a major module for imapsync, the following command installs it "manually":
$ sudo cpanm Mail::IMAPClient
If you need XOAUTH2 authentication, you have to install the module JSON::WebToken with the command:
$ sudo cpanm JSON::WebToken
After installing the dependencies, download the tar.gz
version of the latest Imapsync release from the official Git repository.
Take the compressed tarball called imapsync-1.xxx.tgz
, where 1.xxx is the version number. Untar the tarball where you want:
$ cd
$ tar xzvf imapsync-1.xxx.tgz
Go into the directory imapsync-1.xxx
$ cd imapsync-1.xxx
You can check the version of Imapsync using the following command.
./imapsync -v
Syncing Emails
The syntax for syncing emails from server1
to server2
using only the required options is shown below.
imapsync --host1 server1.imap.tld --user1 [email protected] --password1 password1 --host2 server2.imap.tld --user2 [email protected] --password2 password2
Passwords
To avoid entering plain text mailbox passwords, you can store them in files and use the --passfile1
and --passfile2
arguments to load them from the files containing the passwords.
imapsync --host1 server1.imap.tld --user1 [email protected] --passfile2 /home/user/pass1 --host2 server2.imap.tld --user2 [email protected] --passfile2 /home/user/pass2
The connection to the IMAP server
Several options are available to connect Imapsync to your mail server, including the type of connection used. By default, Imapsync will try to use SSL or TLS on port 993
to connect. The following are examples of the server's connection to migrate (replace 1
with 2
for the second server).
--nossl1
for an unencrypted connection via port143
(not recommended)--ssl1
for an encrypted connection with SSL via port993
--tls1
to connect with TLS via port993
There are also options to define the type of authentication. This is specified with the --authmech1
and --authmech2
arguments, whose possible values are as follows (in upper case).
PLAIN
LOGIN
CRAM-MD5
Folders
Folder synchronization can cause problems, especially if the default folders (Inbox, Spam, Archive, Sent) are not named the same on both mail servers. Imapsync offers several options for this:
--automap
to use automatic default folder recognition.--nomixfolders
to avoid merging folders with a similar name according to case sensitivity.--prefix1
to remove a prefix from the folders to migrate.--prefix2
to add a prefix to migrated folders.--skipemptyfolders
to not recreate empty folders on the destination server.
Migration options
To speed up email migration, you can use the --usecache
argument to temporarily store the folders on the server where you installed Imapsync.
You can also delete messages from the first server with the --delete1
argument.
Finally, before starting your migration, do not hesitate to use the --dry
argument to check the result of a command without executing it.
More Information
For more information about Imapsync, see the official website.
Want to contribute?
You could earn up to $600 by adding new articles
Recommend
-
70
README.md PHP IMAP
-
31
Join GitHub today GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
-
8
Getting Your Organizations Largest Exchange Mailboxes With PowerShell In a quest to hunt down users with large mailboxes, I wrote the following PowerShell function. It’s made to be run from a
-
15
Get a List of Shared Mailboxes Members and Permissions If you want to get a list of members from an O365 shared mailbox using powershell, you can run either command to do so: Get-Mailbox “Shared...
-
9
Quickly list all mailboxes to which a particular user has access This question seems to get asked a lot, and people are unaware how easy the answer really is. Here it is: List a...
-
8
1. Introduction Mailboxes are one of the fundamental parts of the actor model. Through the mailbox mechanism, actors can decouple the reception of a message from its elaboration. So, let’s see how
-
9
NAKIVO Blog > Office 365 Administration and Deployment > How to Restore Inactive Mailboxes in Office...
-
5
How to Use Minimal Hybrid to Quickly Migrate Exchange Mailboxes to Office 365 ...
-
4
Using a Different System?
-
5
Imapsync rpm for CentOS 5 I needed a tool to synchronize imap folders from one server (M\$ Exchange) to another imap server. Imapsync seemed to be a good tool but didn't exist for CentOS 5 so i've built it :
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK