imapsync
Synchronize IMAP mailboxes
TLDR
Synchronize IMAP account between host1 and host2
SYNOPSIS
imapsync [options] --host1 host --user1 user --password1 pass --host2 host --user2 user --password2 pass
PARAMETERS
--host1 host
Source IMAP server hostname or IP
--host2 host
Destination IMAP server hostname or IP
--user1 user
Source IMAP username
--user2 user
Destination IMAP username
--password1 pass
Source IMAP password (prompt if omitted)
--password2 pass
Destination IMAP password (prompt if omitted)
--port1 port
Source IMAP port (default 143)
--port2 port
Destination IMAP port (default 143)
--ssl1
Enable SSL on source server
--ssl2
Enable SSL on destination server
--tls1
Enable STARTTLS on source
--tls2
Enable STARTTLS on destination
--folder folder
Transfer specific folder (repeatable)
--folderrec folder
Recursively transfer folders
--subscribed
Sync only subscribed folders
--syncinternaldates
Preserve internal message dates
--dry
Dry run: simulate without copying
--delete
Delete messages/folders on dest matching source deletions
--maxage days
Sync messages newer than N days
--maxsize bytes
Skip messages larger than N bytes
--justfolders
Create folders only, no messages
--nofoldersizes
Don't check folder sizes
--regextransf regex
Regex for folder name transforms
--authmech1 mech
Source auth mechanism (PLAIN, LOGIN, etc.)
--buffersize bytes
I/O buffer size (default 8MB)
--pidfile file
PID file for daemon mode
--help
Show full usage
--version
Print version
DESCRIPTION
imapsync is a powerful command-line utility written in Perl for transferring and synchronizing email messages between two IMAP4 servers. It enables seamless mailbox migrations, backups, or ongoing syncs without interrupting service. Key features include recursive folder copying, message filtering by date/size/flags, deletion synchronization, and preservation of internal dates, flags, labels, and ACLs. It supports SSL/TLS, authentication methods like CRAM-MD5 and DIGEST-MD5, and handles duplicates via unique identifiers (UIDs). Ideal for server migrations, consolidations, or replicating mailboxes across providers like Gmail, Outlook, or self-hosted setups. Usage is straightforward: specify source and destination server credentials, select folders, and run. Dry-run mode (--dry) allows testing without changes. For large mailboxes, it resumes interrupted transfers and throttles connections to avoid overwhelming servers. Despite its age, it remains a go-to tool due to reliability and minimal dependencies.
CAVEATS
Resource-intensive for millions of emails; requires Perl modules (IO::Socket::SSL, etc.); single-threaded, so slow on very large accounts; potential issues with proprietary IMAP extensions (e.g., Gmail labels); use --timeout to handle slow connections; not actively maintained since author's passing in 2022.
INSTALLATION
Available via apt (apt install imapsync), yum, or Perl CPAN: cpan App::Imapsync. Requires Mail::IMAPClient and other modules.
BASIC EXAMPLE
imapsync --host1 imap.old.com --user1 user@old --password1 pass1 --host2 imap.new.com --user2 user@new --password2 pass2 --folderrec Inbox --syncinternaldates
Dry-run first with --dry.
HISTORY
Developed by Gilles Lamiral starting in 2001 as a Perl script for IMAP syncing. Gained popularity for migrations in early 2000s hosting era. Reached version 2.x by 2020s with thousands of downloads. Archived post-2022 due to author's death, but forks like imapsync-community continue enhancements.
SEE ALSO
offlineimap(1), mbsync(1), doveadm-sync(1), mutt(1)


