Fix imapsync Migration Dates in Gmail

Why imapsync Migrations Show the Wrong Date in Gmail

imapsync is frequently used to migrate mailboxes to Gmail and Google Workspace accounts via IMAP. When imapsync uploads messages to Gmail's IMAP interface, Gmail processes each message through its own mail pipeline. Even when the --syncinternaldates flag is specified, Gmail's IMAP implementation may override the requested INTERNALDATE in certain situations, particularly when the message goes through Gmail's spam and security filters.

Gmail's IMAP behavior is notably different from standard IMAP servers. Gmail adds its own Received header (typically containing "gmailapi.google.com" or the IMAP gateway identifier) with the upload timestamp. Additionally, Gmail's handling of the APPEND command with a specified INTERNALDATE is not always consistent. Some messages receive the requested date, while others are stamped with the upload timestamp, creating an unpredictable mix of correct and incorrect dates within the same migrated mailbox.

For Gmail web users, the display date is derived from the Date header, which masks the INTERNALDATE issue. But users who connect to their Gmail account via Outlook, Apple Mail, or Thunderbird see the migration date on affected messages. The inconsistency between Gmail web and IMAP clients creates confusion, and the partial nature of the problem (some dates correct, some not) makes it even harder to diagnose and quantify the scope of affected messages.

How This Affects Gmail

Gmail's dual-date behavior means the problem is invisible in the Gmail web interface but fully visible in IMAP clients. Users who only use Gmail in a browser may never notice the issue. Users who connect Outlook, Apple Mail, or Thunderbird to the same Gmail account see the migration date on affected emails. This inconsistency leads to conflicting user reports that complicate support efforts.

Gmail's IMAP search (SEARCH SINCE/BEFORE commands) uses the INTERNALDATE, so IMAP clients that perform server-side date searches return incorrect results. Third-party backup tools that connect to Gmail via IMAP archive the wrong dates, creating permanent inaccuracies in backup records. Google Vault and Workspace compliance tools may also reference the INTERNALDATE for date-based holds, potentially impacting legal and regulatory workflows.

Frequently Asked Questions

Why does imapsync --syncinternaldates not work reliably with Gmail?

Gmail IMAP implementation has specific behaviors that differ from standard IMAP servers. Gmail may override the requested INTERNALDATE during its internal processing pipeline, especially when messages pass through spam filters or security scanning. This is a Gmail-specific behavior, not an imapsync bug.

How can I tell which emails in Gmail have the wrong INTERNALDATE?

Redate.io scans the mailbox and identifies emails where the INTERNALDATE does not match the original Date header. The scan is free and shows exactly how many emails are affected, so administrators can assess the scope before committing to a fix.

Does Redate.io handle Gmail labels when fixing dates?

Yes. Redate.io preserves all Gmail labels, stars, read/unread status, and other metadata when correcting the email. The fixed message appears in the same location with the same labels as the original.

Start Free Scan