Email migration is the process of transferring mailbox data from one email account or server to another. Organizations often perform migrations when switching hosting providers, upgrading mail servers, or consolidating email infrastructure.
One of the most reliable tools for performing email migration on Linux servers is imapsync. This command-line utility allows administrators to transfer emails between two IMAP servers efficiently. It supports incremental synchronization, meaning that only new or missing messages are transferred, which helps reduce bandwidth usage and migration time.
Imapsync also preserves message flags and folder structures, ensuring that the migrated mailbox remains identical to the original one.
What is the Imapsync Command?
Imapsync is a powerful tool designed for transferring email messages between two IMAP servers. It performs a recursive synchronization of all mailbox folders by default.
One of the key advantages of imapsync is that it avoids duplicate transfers. The tool compares messages on both servers based on headers and size. If a message already exists on the destination server, it is skipped.
Additional benefits include:
- Incremental synchronization
- Preservation of message status (read, unread, deleted)
- Reliable operation even with unstable network connections
- Ability to pause and resume migrations
Because of these features, imapsync is widely used for server migrations and mailbox transfers.
Basic Imapsync Command Usage
The general syntax of the imapsync command is:
imapsync [options] Some parameters are mandatory for a successful migration.
Required Parameters
| Option | Description |
|---|---|
--host1 | Source IMAP server |
--user1 | Source email account |
--password1 | Password for source account |
--host2 | Destination IMAP server |
--user2 | Destination email account |
--password2 | Password for destination account |
By default, the IMAP connection uses port 143.
Important Imapsync Options
Imapsync includes many options that allow administrators to customize the migration process.
Authentication and Security
| Option | Description |
|---|---|
--ssl1 | Enable SSL for source server |
--ssl2 | Enable SSL for destination server |
--tls1 | Enable TLS for source server |
--tls2 | Enable TLS for destination server |
--authmech1 | Authentication method for host1 |
--authmech2 | Authentication method for host2 |
Folder Synchronization Options
| Option | Description |
|---|---|
--folder | Sync specific folder |
--folderrec | Sync folder recursively |
--include | Include folders matching pattern |
--exclude | Exclude folders matching pattern |
Message Filtering Options
| Option | Description |
|---|---|
--maxsize | Skip messages larger than given size |
--maxage | Skip messages older than specified days |
--minage | Skip messages newer than specified days |
Migration Behavior Options
| Option | Description |
|---|---|
--delete | Delete messages from source after transfer |
--expunge | Permanently remove deleted messages |
--syncinternaldates | Preserve original message timestamps |
Examples of Imapsync Commands
Test Email Migration
Before performing the actual migration, it is recommended to test the command using the –dry option. This simulates the migration without transferring emails.
imapsync --noauthmd5 \
--host1 source.server.com --user1 user@domain.com --password1 password1 \
--host2 destination.server.com --user2 user@domain.com --password2 password2 \
--dry Perform Email Migration
To perform the actual migration, run the same command without the –dry option.
imapsync --noauthmd5 \
--host1 source.server.com --user1 user@domain.com --password1 password1 \
--host2 destination.server.com --user2 user@domain.com --password2 password2 Exclude Specific Folders During Migration
You can exclude certain folders while migrating email.
imapsync --host1 source.server.com --user1 user@domain.com --password1 password1 \
--host2 destination.server.com --user2 user@domain.com --password2 password2 \
--exclude 'INBOX.Spam|INBOX.Trash' --subscribe_all Migrate Only a Specific Folder
To migrate a particular folder, use the –folder option.
imapsync --host1 source.server.com --user1 user@domain.com --password1 password1 \
--host2 destination.server.com --user2 user@domain.com --password2 password2 \
--folder INBOX.2024 POP to IMAP Email Migration
In some cases, administrators may need to migrate emails from a POP account to an IMAP server. This can be done using the pop2imap command.
Example:
/usr/bin/pop2imap \
--host1 pop.domain.com --user1 user1 --passfile1 /etc/pass1 \
--host2 imap.domain.com --user2 user2 --passfile2 /etc/pass2
This tool transfers messages from a POP mailbox into an IMAP account.
Manual Email Migration Method
If command-line migration tools are not available, email migration can also be performed manually using an email client.
Steps for Manual Migration
- Create two email accounts in an email client such as Outlook.
- Configure one account with the source mail server settings.
- Configure the second account with the destination mail server settings.
- Allow the email client to download messages from the source server.
- Drag and copy emails or folders from the source account to the destination account.
Although this method is slower, it can be useful for small mailbox migrations.
Conclusion
Email migration is an essential task when changing mail servers or consolidating email systems. Tools like imapsync simplify this process by allowing administrators to transfer mailboxes between IMAP servers efficiently.
With features such as incremental synchronization, message comparison, and folder preservation, imapsync ensures reliable and accurate migrations. It also supports advanced filtering and migration options that make it suitable for both small and large mailbox transfers.
Whether you are migrating a single mailbox or performing a large-scale server migration, understanding how to use imapsync can significantly simplify the process.
Need Help with Email Migration?
If you need assistance with email migration, IMAP synchronization, or server administration, contact SupportPRO Server Admin for professional support and migration services.
Partner with SupportPRO for 24/7 proactive cloud support that keeps your business secure, scalable, and ahead of the curve.
