Open-source project
imapsync/imapsync avatar
imapsync/imapsync

imapsync: One-Way IMAP Migration and Backup Tool

Imapsync is an IMAP transfers tool. The purpose of imapsync is to migrate IMAP accounts or to backup IMAP accounts. IMAP is one of the three current standard protocols to access mailboxes, the two others are POP3 and HTTP with webmails, webmails are often tied to an IMAP server. Upstream website is

4,169 stars532 forksShellNOASSERTION

At a glance

What is it?
imapsync is a command-line tool for transferring email from one IMAP account to another. It transfers all folders, sub-folders, and flags incrementally, skipping messages already present on the destination, and can be interrupted and resumed at any point.
Who is it for?
imapsync is the right tool for migrating an IMAP account from one server to another, or for creating a one-way backup of a mailbox. It is explicitly not suitable for keeping two active IMAP accounts synchronized in both directions when users independently add or delete mail on each side; the README recommends offlineimap or mbsync for that use case.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 6 days ago.
What is it written in?
Mainly Shell, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What imapsync Does and Who Uses It

imapsync transfers email from a source IMAP account to a destination IMAP account. The README describes its purpose as allowing incremental and recursive IMAP transfers from one mailbox to another. It is commonly used in two scenarios: migrating a mailbox from one email server to another when an organization changes providers, and creating a backup copy of a mailbox in a second IMAP account.

The tool connects to both IMAP servers simultaneously. It reads folders and messages from the source, checks what already exists on the destination, and transfers only what is missing. This incremental design means you can run imapsync multiple times and it will only transfer new messages, which reduces bandwidth and time for repeated backup runs.

The tool is distributed as a Perl script. It runs on Linux, macOS, and Windows. The README references a companion website at imapsync.lamiral.info for additional documentation and support resources. The current documented revision is 2.314, as stated in the README. The repository's top-level directory includes a FAQ file, a ChangeLog, an INSTALL file with installation steps, and a CREDITS file. The examples/ directory contains platform-specific shell scripts and batch files covering common sync scenarios including OAuth2 authentication and parallel sync.

The IMAP protocol is one of the three standard protocols for accessing email; the others are POP3 and HTTP-based webmail. imapsync works with any IMAP-compliant server, which includes most modern email providers.

Running a Basic Sync

The standard usage requires six values: hostname, username, and password for each of the two IMAP servers. The README gives this example:

code
imapsync \
 --host1 test1.lamiral.info --user1 test1 --password1 secret1 \
 --host2 test2.lamiral.info --user2 test2 --password2 secret2

This transfers all folders and messages from the account test1 on test1.lamiral.info to the account test2 on test2.lamiral.info. By default, no messages on the destination are deleted, even if they are absent from the source.

The README explains how to verify a successful run. A successful sync produces these lines near the end of the output:

code
The sync looks good, all 1745 identified messages in host1 are on host2.
There is no unidentified message on host1.
Detected 0 errors

And then the final exit lines:

code
Exiting with return value 0 (EX_OK: successful termination) 0/50 nb_errors/max_errors PID 20332
Removing pidfile /home/gilles/tmp/imapsync.pid

If those final lines do not appear, the process either is still running or was killed with a strong signal.

How Duplicate Detection Works

imapsync identifies whether a message is already on the destination by comparing header values. The default identification headers are Message-Id: and Received:. If a message with matching headers is found on the destination, it is not transferred again.

The README notes that this choice can be changed with the --useheader option. For mailboxes where duplicate detection fails, the README suggests using --useheader "Message-Id" to rely on only the Message-Id header. This is the most common fix when the same message appears on both sides with slightly different Received headers because the IMAP servers handle headers differently.

Message sizes are explicitly excluded from the identification criteria. The README explains that imap servers often report sizes that differ slightly from the actual transferred message size, and using size as a criterion caused false negatives in earlier versions of the tool.

Flags are preserved and re-synchronized on each run. If a message was read on the source after the last sync, the flag update is applied to the destination on the next run. The --noresyncflags option disables this behavior if flag synchronization is unwanted.

Strict Sync, Source Deletion, and Folder Management Options

By default, imapsync never deletes anything from the destination. If a message exists on the destination but not on the source, it stays. For a strict mirror where the destination must exactly match the source, the --delete2 option removes messages on the destination that are no longer on the source.

For folder management: --delete2folders deletes entire folders on the destination that do not exist on the source. The README documents --delete2foldersonly and --delete2foldersbutnot as options to restrict which folders are subject to deletion. The INBOX folder is never deleted; it is a mandatory folder in the IMAP protocol, and imapsync will not attempt to remove it.

For migration scenarios where the source account should be cleaned up after transfer, the --delete1 option deletes messages from the source after they are successfully transferred. The README notes that --delete1 implies --expunge1, which permanently removes messages marked as \Deleted on the source. Adding --delete1emptyfolders removes source folders that become empty after all their messages are transferred.

The --dry option makes imapsync report what it would do without actually transferring or deleting anything.

What imapsync Cannot Do: Two-Way Sync and Active Accounts

The README is explicit about a hard limitation: imapsync is not adequate for maintaining two active IMAP accounts in synchronization when the user makes independent changes on both sides. If a user reads or deletes mail on both the source and the destination between syncs, imapsync cannot reconcile those changes safely. It only transfers messages one way.

For two-way synchronization, the README names two alternatives: offlineimap, written by John Goerzen, and mbsync, written by Michael R. Elkins. Both tools are designed for bidirectional sync and handle conflict cases that imapsync does not address.

Imapsync also does not handle calendar data, contact sync, or any IMAP extensions that operate outside standard email message storage. If the IMAP accounts are part of a groupware system with calendars or tasks stored in IMAP folders, those may transfer as raw data but any application-level semantics are not preserved by imapsync.

License, Resumability, and Windows Notes

The repository's LICENSE file does not carry a recognized OSI-approved license identifier; the metadata field in the pack is listed as NOASSERTION. The homepage imapsync.lamiral.info is the authoritative source for licensing terms. Teams with compliance requirements should review that site before deploying imapsync.

imapsync is designed for interrupted-and-resumed use. The README states that the tool works well with bad connections and interruptions by design. On a terminal, pressing Ctrl-C once reconnects to both IMAP servers, and pressing it twice within two seconds aborts the program. Restarting imapsync after an abort picks up where it left off, because already-transferred messages are identified and skipped.

The README includes a dedicated Windows readme at README_Windows.txt. The repository also contains example scripts for several scenarios: examples/imapsync_example.sh for a basic Unix example, examples/imapsync_example.bat for Windows, examples/sync_loop_unix.sh for repeated sync loops, examples/sync_parallel_unix.sh for parallel sync runs, and examples/imapsync_example_oauth2.bat for OAuth2 authentication on Windows. The last push was on 2026-09-24.

The Makefile target make testp checks that all required Perl modules are available from your distribution or CPAN before attempting a full install. Running make install as root completes the installation. These steps are documented in the repository's INSTALL file and the Makefile help output.

Editorial conclusion

imapsync is the right tool for migrating an IMAP account from one server to another, or for creating a one-way backup of a mailbox. It is explicitly not suitable for keeping two active IMAP accounts synchronized in both directions when users independently add or delete mail on each side; the README recommends offlineimap or mbsync for that use case. Before running imapsync on a production mailbox, verify the license terms on imapsync.lamiral.info, as the LICENSE file in the repository does not carry a recognized open source identifier. The current version documented in the README is revision 2.314.

Frequently asked questions

What is imapsync used for?

imapsync transfers email from one IMAP account to another, one way. The README describes two main use cases: migrating a mailbox from an old server to a new one when changing providers, and creating a backup copy of a mailbox in a second IMAP account.

How do I use imapsync?

Run imapsync with the --host1, --user1, --password1 flags for the source account and --host2, --user2, --password2 for the destination. All folders are transferred recursively. Existing messages on the destination are skipped. Add --delete2 if you want messages removed from the destination that are absent from the source.

What is the difference between imapsync and offlineimap?

imapsync is a one-way migration and backup tool. The README explicitly states it is not adequate for keeping two active accounts synchronized when both sides change independently. offlineimap is designed for bidirectional sync between a local maildir store and an IMAP server, and handles changes on both sides.

Official sources

  1. imapsync/imapsync on GitHub
  2. Issues
  3. Project website
  4. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/imapsync-imapsync.svg)](https://hysenlabs.com/projects/imapsync-imapsync)