In email server changes, transferring user accounts and their contents from the old server to the new server is a critical process. imapsync
is one of the most reliable open-source tools for this task. Especially with version v3, it offers a more stable, faster, and compatible structure. In this article, we explain in detail how to perform email migration between two different IMAP servers using Imapsync v3.
1. What is Imapsync?
Imapsync is a command-line tool used to securely copy or move email content between two email servers using the IMAP protocol. It can perform migration without deleting, and can synchronize only new emails.
2. Requirements
-
Debian/Ubuntu system
-
Perl 5.30+ and related modules
-
Root or sudo access
3. Imapsync v3 Installation
apt update && apt upgrade -y
apt install git make cpanminus libauthen-ntlm-perl libterm-readkey-perl -y
cd /usr/local/src
wget https://github.com/imapsync/imapsync/archive/refs/tags/rel3.1.6.tar.gz
tar xzf rel3.1.6.tar.gz
cd imapsync-rel3.1.6
make install
Alternatively, for quick installation:
apt install imapsync -y # Also available in Debian/Ubuntu repositories (may be outdated in some versions)
4. Usage Format
imapsync \
--host1 mail.oldserver.com --user1 [email protected] --password1 'old_password' \
--host2 mail.newserver.com --user2 [email protected] --password2 'new_password' \
--ssl1 --ssl2 --syncinternaldates --authmech1 LOGIN --authmech2 LOGIN
Explanation:
-
--ssl1
and--ssl2
: SSL is enforced on both servers -
--syncinternaldates
: Preserves the original dates of the emails -
--authmech
: Login method (LOGIN, PLAIN, etc.)
5. Migration with a List for Automation
Example user list:
[email protected];[email protected];password1;password2
[email protected];[email protected];password3;password4
Bulk migration with script:
#!/bin/bash
while IFS=';' read -r u1 u2 p1 p2; do
imapsync --host1 mail.old.com --user1 "$u1" --password1 "$p1" \
--host2 mail.new.com --user2 "$u2" --password2 "$p2" \
--ssl1 --ssl2 --syncinternaldates
echo "$u1 → $u2 completed"
done < users.txt
6. Frequently Used Additional Parameters
Parameter | Description |
---|---|
--delete2 |
Deletes emails not present in the source (CAREFUL) |
--exclude "Trash" |
Does not move the Trash folder |
--addheader |
Adds the migration date to the migrated email |
--fast |
Faster matching algorithm |
7. Recommended Usage Strategy
-
Run on small accounts for pre-testing.
-
Test with
--dry
before the actual migration. -
Increase speed with
--nofoldersizes
on large accounts. -
After the process is complete, request verification from the user on the target server.
Imapsync v3 is a powerful solution for fast and reliable email migration operations. The entire process can be managed directly via SSH without using a control panel. It is a preferred tool for both corporate and individual migrations, and when used with the correct parameters, it can successfully perform mail migration without data loss.