Migrating Email Between Servers: Modern Alternatives to IMAPcopy (2025 Guide)
Migrating email accounts between servers is one of those critical tasks that can make or break a hosting provider's reputation. Whether you're moving clients to new infrastructure, consolidating mail servers, or helping customers switch hosting providers, having reliable email migration tools is essential.
For years, IMAPcopy was the go-to solution for transferring email between IMAP servers. While it served its purpose well, the email landscape has evolved significantly. Modern alternatives offer better performance, more features, and active maintenance. In this comprehensive guide, we'll explore the best tools for email migration in 2025.
Why Email Migration Still Matters
Email migration might seem straightforward—it's just copying files from one server to another, right? Unfortunately, it's more complex than that. A proper email migration must:
- Preserve folder hierarchies and subscription status
- Maintain message flags (read/unread, flagged, replied, etc.)
- Keep original timestamps and headers intact
- Handle large mailboxes efficiently (100GB+ is common today)
- Work with various IMAP server implementations (Dovecot, Courier, Exchange, Gmail, etc.)
- Minimize downtime during the transition
- Verify data integrity after transfer
Poor email migration can result in lost messages, angry customers, and significant business disruption. That's why choosing the right tool matters.
The Best Email Migration Tools for 2025
1. Imapsync: The Industry Standard
Imapsync has become the de facto standard for email migration. It's a mature, actively maintained Perl script that handles complex migration scenarios with ease.
Key Features:
- Incremental sync (run multiple times to catch new messages)
- Bandwidth throttling to avoid overloading servers
- Extensive logging for troubleshooting
- Handles folder mapping and renaming
- Works with nearly all IMAP servers
- Can migrate millions of mailboxes
Installation:
On most Linux distributions:
# Debian/Ubuntu
sudo apt-get install imapsync
# RHEL/Rocky Linux/AlmaLinux
sudo dnf install imapsync
# Or install from source
git clone https://github.com/imapsync/imapsync.git
cd imapsync
sudo make install
Basic Usage:
imapsync \
--host1 source.mailserver.com --user1 user@example.com --password1 'source_password' \
--host2 destination.mailserver.com --user2 user@example.com --password2 'dest_password' \
--ssl1 --ssl2
Advanced Example with Options:
imapsync \
--host1 old.mailserver.com \
--user1 john@example.com \
--password1 'source_pass' \
--host2 new.mailserver.com \
--user2 john@example.com \
--password2 'dest_pass' \
--ssl1 --ssl2 \
--syncinternaldates \
--exclude '(?i)\b(Junk|Spam|Trash)\b' \
--automap \
--maxbytespersecond 1000000 \
--useheader 'Message-ID' \
--skipsize \
--dry
What these options do:
--syncinternaldates: Preserves original message dates--exclude: Skips Junk/Spam/Trash folders--automap: Automatically maps common folder names--maxbytespersecond: Limits bandwidth usage to 1MB/s--useheader 'Message-ID': Uses Message-ID to avoid duplicates--skipsize: Skips size comparison (faster)--dry: Test run without actually transferring (remove when ready)
Pro Tips:
- Always run with
--dryfirst to test - Use
--justfoldersto verify folder structure before full sync - For Gmail migrations, add
--gmail1or--gmail2flags - Enable logging with
--logand--logfile /path/to/logfile.txt
2. mbsync (isync): Efficient and Fast
mbsync (part of the isync package) is designed for synchronizing IMAP mailboxes. While originally built for local sync, it excels at server-to-server migrations.
Key Features:
- Extremely fast with large mailboxes
- Bidirectional synchronization
- Efficient use of IMAP IDLE
- Lower memory footprint than imapsync
- Configuration file-based (great for scripting multiple migrations)
Installation:
# Debian/Ubuntu
sudo apt-get install isync
# RHEL/Rocky Linux
sudo dnf install isync
# macOS
brew install isync
Configuration:
mbsync uses a configuration file (~/.mbsyncrc):
IMAPAccount source
Host source.mailserver.com
User user@example.com
Pass source_password
SSLType IMAPS
IMAPStore source-remote
Account source
IMAPAccount destination
Host destination.mailserver.com
User user@example.com
Pass dest_password
SSLType IMAPS
IMAPStore destination-remote
Account destination
Channel migration
Far :source-remote:
Near :destination-remote:
Patterns *
Create Both
Sync All
Expunge Both
Usage:
mbsync -a # Sync all channels
mbsync migration # Sync specific channel
Best Use Cases:
- Large mailboxes (50GB+)
- Ongoing synchronization scenarios
- When you need bidirectional sync
- Batch migrations with configuration files
3. doveadm (Dovecot Admin Tool)
If you're running Dovecot as your IMAP server, doveadm provides native migration capabilities that are blazingly fast.
Key Features:
- Native Dovecot integration
- Fastest option for Dovecot-to-Dovecot migrations
- Can access mailbox directly or via IMAP
- Built-in deduplication
- Supports dsync protocol for efficient transfer
Basic IMAP Migration:
doveadm backup -u user@example.com -R imapc:
With configuration:
# Add to /etc/dovecot/dovecot.conf or a separate config file
imapc_host = source.mailserver.com
imapc_port = 993
imapc_ssl = imaps
imapc_user = user@example.com
imapc_password = source_password
imapc_features = rfc822.size fetch-headers
# Then run:
doveadm -o imapc_host=source.mailserver.com \
-o imapc_user=user@example.com \
-o imapc_password=source_password \
-o imapc_ssl=imaps \
backup -R -u user@example.com imapc:
Best Use Cases:
- Dovecot-to-Dovecot migrations
- Migrations where you have direct server access
- Bulk migrations of many accounts
- When maximum speed is critical
4. OfflineIMAP: Reliable Two-Way Sync
OfflineIMAP synchronizes IMAP mailboxes bidirectionally. While development has slowed, it remains reliable for many use cases.
Key Features:
- Bidirectional synchronization
- Can use local Maildir as intermediate storage
- Python-based with extensive configuration options
- Good for complex folder mapping scenarios
Installation:
# Most Linux distributions
sudo apt-get install offlineimap
# Or via pip
pip3 install offlineimap3
Comparing Email Migration Tools
| Feature | Imapsync | mbsync | doveadm | OfflineIMAP |
|---|---|---|---|---|
| Ease of Use | Command-line | Config file | Command-line | Config file |
| Speed | Fast | Very Fast | Fastest* | Moderate |
| Active Development | Yes | Yes | Yes | Limited |
| Server Support | Universal | Universal | Dovecot-focused | Universal |
| Incremental Sync | Yes | Yes | Yes | Yes |
| Bandwidth Control | Yes | Limited | No | Yes |
| Best For | General use | Large mailboxes | Dovecot servers | Complex scenarios |
| Learning Curve | Low | Medium | Medium-High | High |
*For Dovecot-to-Dovecot migrations
Best Practices for Email Migration
1. Test First, Migrate Later
Always perform a test migration with a sample account before migrating production mailboxes. This helps you:
- Identify authentication issues
- Test folder mapping
- Estimate transfer times
- Verify data integrity
2. Use Incremental Migrations
For large migrations or minimal downtime:
- Perform initial bulk sync while old server is still active
- Schedule final incremental sync during maintenance window
- Update DNS/MX records
- Run one more incremental sync to catch any last messages
3. Preserve Email Headers
Original message timestamps and headers are crucial for compliance, legal discovery, and user experience. Always use options that preserve:
- Internal dates
- Message-ID headers
- Received headers
- Original timestamps
4. Handle Special Folders
Different IMAP servers name special folders differently:
- Sent Mail vs Sent Items vs Sent
- Junk vs Spam vs Junk E-mail
- Deleted Items vs Trash
Use mapping features to ensure folders end up in the right place.
5. Monitor and Log Everything
Enable detailed logging to track:
- Number of messages transferred
- Errors and failures
- Transfer speeds
- Folder mapping issues
6. Verify After Migration
Don't assume the migration succeeded. Verify:
# Compare message counts
imapsync --host1 source --user1 user@example.com --password1 'pass' \
--host2 dest --user2 user@example.com --password2 'pass' \
--justfoldersizes
7. Have a Rollback Plan
Keep the source server active for at least a week after migration. This allows you to:
- Catch any missed messages
- Handle user complaints
- Roll back if serious issues arise
Handling Common Migration Challenges
Large Mailboxes (50GB+)
For very large mailboxes:
- Use bandwidth limiting to avoid server overload
- Consider migrating in stages (by folder or date range)
- Schedule during off-peak hours
- Use
mbsyncordoveadmfor better performance
# Imapsync with bandwidth limiting
imapsync --host1 source --user1 user@example.com --password1 'pass' \
--host2 dest --user2 user@example.com --password2 'pass' \
--maxbytespersecond 500000 \ # 500KB/s
--maxmessagespersecond 10
Different Folder Encodings
Some servers use UTF-7 modified encoding for folder names. Imapsync handles this automatically, but if you encounter issues:
imapsync --host1 source --user1 user@example.com --password1 'pass' \
--host2 dest --user2 user@example.com --password2 'pass' \
--automap \
--regextrans2 's/Sent/Sent Items/'
Gmail Migrations
Gmail requires app-specific passwords and has special handling:
imapsync --host1 imap.gmail.com --user1 user@gmail.com \
--password1 'app-specific-password' \
--gmail1 \
--host2 destination.mailserver.com --user2 user@example.com \
--password2 'dest_password' \
--ssl1 --ssl2 \
--exclude '\[Gmail\]' \
--automap
Microsoft 365 / Exchange
Modern Authentication with OAuth2 is increasingly required:
# Imapsync with OAuth2 (requires setup)
imapsync --host1 outlook.office365.com --user1 user@example.com \
--password1 'oauth2-token' \
--authmech1 XOAUTH2 \
--host2 dest --user2 user@example.com --password2 'pass'
Automating Bulk Migrations
When migrating many accounts, automation is essential. Here's a shell script example:
#!/bin/bash
# bulk_email_migration.sh
SOURCE_HOST="source.mailserver.com"
DEST_HOST="destination.mailserver.com"
LOG_DIR="/var/log/email-migrations"
ACCOUNT_LIST="/path/to/accounts.txt"
mkdir -p "$LOG_DIR"
# accounts.txt format: email|source_password|dest_password
while IFS='|' read -r EMAIL SOURCE_PASS DEST_PASS; do
echo "Migrating $EMAIL..."
imapsync \
--host1 "$SOURCE_HOST" --user1 "$EMAIL" --password1 "$SOURCE_PASS" \
--host2 "$DEST_HOST" --user2 "$EMAIL" --password2 "$DEST_PASS" \
--ssl1 --ssl2 \
--syncinternaldates \
--automap \
--useheader 'Message-ID' \
--logfile "$LOG_DIR/${EMAIL}.log" \
--pidfile "$LOG_DIR/${EMAIL}.pid"
if [ $? -eq 0 ]; then
echo "$EMAIL: SUCCESS" >> "$LOG_DIR/summary.log"
else
echo "$EMAIL: FAILED" >> "$LOG_DIR/summary.log"
fi
sleep 5 # Brief pause between accounts
done < "$ACCOUNT_LIST"
echo "Migration complete. Check $LOG_DIR/summary.log for results."
Security Considerations
Protect Credentials
Never hardcode passwords in scripts. Use:
- Environment variables
- Secure credential stores (like HashiCorp Vault)
- Encrypted password files with restricted permissions
- SSH key authentication where possible
Encrypt During Transfer
Always use SSL/TLS:
--ssl1and--ssl2flags for imapsyncSSLType IMAPSin mbsync- Verify certificates aren't being bypassed
Audit Trail
Maintain logs of:
- What was migrated
- When it was migrated
- Who initiated the migration
- Any errors or issues
Performance Optimization Tips
- Run migrations from a server close to both source and destination - Network latency matters
- Use multiple simultaneous connections - Most tools support this
- Migrate during off-peak hours - Less server load means faster transfers
- Consider direct server-to-server if possible - Skip IMAP entirely with
rsyncfor Maildir - Monitor resource usage - CPU, memory, and bandwidth can be bottlenecks
When to Use What Tool
Use Imapsync when:
- You need maximum compatibility
- Migrating between different server types
- You want detailed logging and troubleshooting
- You're doing one-time migrations
Use mbsync when:
- Performance is critical
- You have large mailboxes
- You need bidirectional sync
- You're comfortable with configuration files
Use doveadm when:
- Both servers run Dovecot
- You need maximum speed
- You have direct server access
- You're migrating many accounts
Use OfflineIMAP when:
- You need complex folder mapping
- You want local intermediate storage
- You're dealing with unusual server configurations
Troubleshooting Common Issues
Authentication Failures
# Test IMAP connection manually
openssl s_client -connect mailserver.com:993
# Then try: a001 LOGIN user@example.com password
Timeout Errors
Increase timeout values:
imapsync ... --timeout 300 --timeout1 300 --timeout2 300
Folder Creation Failures
Check destination server quotas and permissions:
doveadm quota get -u user@example.com
Duplicate Messages
Use Message-ID for deduplication:
imapsync ... --useheader 'Message-ID' --skipsize
Conclusion
Email migration doesn't have to be painful. Modern tools like imapsync, mbsync, and doveadm make the process reliable and efficient when used correctly. The key is choosing the right tool for your specific scenario, testing thoroughly, and following best practices.
For most hosting providers and system administrators, imapsync remains the best all-around choice due to its flexibility, compatibility, and extensive feature set. However, don't overlook mbsync and doveadm for scenarios where they excel.
Remember: successful email migration is about planning, testing, and verification—not just running a command and hoping for the best. Take your time, test thoroughly, and your users will thank you for a smooth transition.
At Falcon Internet, we provide reliable web hosting solutions with expert support for email hosting and migration. Whether you're managing a VPS or need assistance with email server configuration, our team can help ensure your email infrastructure is robust and reliable.
Have you had experience with email migrations? What tools and techniques have worked best for you? Share your experiences in the comments below!