Apr 28, 2026•6 min read
ArchitectureIMAPZero-Downtime

Migrating 100,000+ mailboxes from Google Workspace without dropping a single email

How we engineered a streaming IMAP synchronization pipeline that preserves message hierarchies, migrates attachments in parallel, and verifies DNS cutover without duplicate UID propagation.

Parminder Singh
Parminder Singh
Founder & Architect, Kosh
IMAP Streaming PipelineActive (100% Synced)
Source: Google Workspace42,890 / 42,890 messages

Continuous delta polling active • Zero UID collisions detected

Email migration is universally feared by IT teams. When a 50-person startup switches email providers, they dread lost threads, altered timestamps, and hours of DNS uncertainty during cutover. Here is how we engineered Kosh's zero-downtime migration engine.

The Challenge with Legacy IMAP Sync

Standard IMAP tools crawl folders sequentially: fetch message headers, download RFC-822 bodies, and append them to the target server. For mailboxes containing 100,000+ emails and gigabytes of attachments, sequential sync takes days and frequently trips Gmail API rate limits.

Furthermore, if an email arrives during migration, traditional scripts either duplicate the message or drop it altogether.

Parallel Chunked Streaming Architecture

Kosh approaches synchronization as a continuous log replication problem. We divide mailboxes into deterministic time slices and execute parallel streaming pipelines across isolated worker threads.

Smart Delta Sync

Once the historical archive is transferred, Kosh enters a high-frequency polling phase. When you update your MX records, remaining incoming delta emails are merged seamlessly.

Worker Job Specjson
{
  "source_provider": "google_workspace",
  "mailbox": "team@startup.com",
  "batch_size": 500,
  "concurrency": 8,
  "preserve_flags": ["\Seen", "\Flagged", "\Draft"],
  "deduplication_mode": "message_id_hash"
}

Zero-Downtime DNS Verification

During final MX cutover, our edge edge-routers accept connections for your domain while your previous records propagate. Messages sent to either your old or new MX server are captured and deduplicated in real time.

  • Continuous synchronization with sub-second message deduplication
  • Automatic flag and label preservation (Starred, Archive, Sent, Custom Folders)
  • Instant fallback if Google or Microsoft throttles IMAP connection limits

Key Takeaway

Switching from legacy suites to a private custom-domain setup shouldn't require a weekend of panic. With deterministic streaming, moving your entire organization's communication history takes just a few clicks.

Parminder Singh

Parminder Singh

Author

Founder & Architect, Kosh

Building private, transparent email infrastructure for modern teams and creators.

Ready to get started?

Join thousands of users who are already building the future with Kosh.