Why we engineered a custom migration engine in Rust
At YYCIT, our clients depend on uninterrupted communication and zero tolerance for data loss. Off-the-shelf migration scripts and bloated third-party SaaS transfer tools often suffer from high memory consumption, opaque error handling, and unverified data transfers. To deliver deterministic reliability, our systems team engineered a dedicated, high-performance IMAP migration engine built in modern Rust (v1.85+).
Rust's strict type safety and memory model make it a good foundation for a network tool that must never corrupt what it carries. Our engine copies messages sequentially with bounded memory (a peak of 17 to 35 MiB in our benchmark), applies network timeouts and per-message size limits, and follows the core RFC 3501 and RFC 9051 IMAP standards, including modified UTF-7 and negotiated UTF-8 folder names.
Strict read-only safety on the source server
The cardinal rule of systems engineering is to never mutate data on a production source server during an export. Standard IMAP tools frequently issue state-altering commands that mark unread messages as read or interfere with active client sessions.
Our engine enforces absolute non-destructive safety by opening source folders exclusively via the IMAP EXAMINE command (the read-only equivalent of SELECT). Furthermore, message bodies are extracted using BODY.PEEK[] rather than BODY[], ensuring that the tool does not change message flags or seen states on the source server. The source adapter exposes no write, flag-update, delete, expunge or subscription operation, and the engine never uses IMAP MOVE. If a cutover needs to be rescheduled, the source mailboxes are exactly as the tool found them. Server access logs and server-side bookkeeping remain outside any client's control.
Resumable local state and cryptographic SHA-256 verification
True migration predictability requires ironclad state tracking and mathematical proof of integrity. Our migration engine incorporates four critical architectural safeguards:
- Local SQLite Transactional State: Every mailbox folder, message UID, transfer timestamp, and verification status is logged in an embedded local SQLite database. If a WAN connection resets, you rerun the same command and it continues from the saved state without re-uploading confirmed messages. New arrivals are picked up by a separate incremental pass, because each job works from a recorded snapshot.
- SHA-256 Read-Back Verification: After each upload, the message is read back from the destination and compared by SHA-256, INTERNALDATE and flags before it is called confirmed. Reports say exactly which level of check each message received, so a lighter metadata check is never presented as a full one.
- Explicit Folder Mapping: IMAP servers separate folder paths differently (such as / or .). An inspect step lists the exact folder names and delimiters on both servers, and each source folder is then mapped one to one to a destination folder. Nothing is guessed or rewritten automatically, which keeps nested archives predictable.
- Additive Copying: Destination mailboxes receive messages additively, so existing mail is kept. Messages flagged \Deleted at the source are never copied with that flag.
Modern authentication: SASL, strict TLS, and XOAUTH2
Modern business infrastructure requires modern cryptographic handshakes. Our migration engine uses implicit TLS (port 993) or mandatory STARTTLS (port 143), validates certificates and hostnames, requires TLS 1.2 or newer, and has no insecure fallback.
For cloud environments, the engine supports SASL XOAUTH2 bearer tokens as well as PLAIN and LOGIN, always inside TLS. XOAUTH2 is implemented but has not yet been validated against live Gmail or Microsoft 365 accounts, so we prove it on a pilot mailbox first. Passwords come from protected files (mode 0600, no symlinks) or terminal prompts, and no secret is ever accepted inline on the command line.
Our four-stage zero-downtime cutover methodology
Having high-reliability tooling is only half the battle; how migrations are staged determines whether your business experiences downtime. Through our dedicated Email Migration Calgary service and business email & identity services, we execute migrations following a disciplined 4-stage playbook. For the measured trade-offs of this engine against imapsync, read our IMAPLANE vs imapsync benchmark:
- Phase 1: Baseline Background Sync: While employees continue working uninterrupted in their day-to-day email client, our engine synchronizes the entire multi-year email archive to the new mail host in the background.
- Phase 2: Pre-Cutover Delta Pass: Before cutover, an incremental pass (migrate --incremental) copies only messages received since the initial baseline.
- Phase 3: DNS MX Record Cutover: We update the domain's MX and SPF/DKIM records with pre-lowered DNS TTLs, directing newly incoming emails directly to the new mail servers.
- Phase 4: Final Catch-Up Sweep: Our engine executes a final pass over the old server to sweep any straggler messages routed during global DNS propagation, followed by a full SHA-256 verification run so the final report accounts for every message.
Written by YYCIT Systems Engineering
We design, deploy, and manage Linux servers, OpenStack clouds, and high-reliability systems for Calgary businesses. Direct engineering access with published $115–$150/hr rates and zero contract lock-in.


