IMAP UIDVALIDITY explained: Why a folder needs to sync again
Learn how IMAP UIDs and UIDVALIDITY identify messages, why a folder can need a fresh sync and how to check your mail safely after a change.
UIDVALIDITY is a value an IMAP server supplies when an email app opens a folder. It tells the app which set of message identifiers the folder currently uses. If the value has changed since the app last connected, the app needs to rebuild its map of that folder. The same message number can now point to a different email. A fresh sync prevents the app from showing the wrong cached body or applying an old action to the wrong message.
If you saw a message about UIDVALIDITY after a host migration or restore, open the affected folder in the provider's webmail and check a few messages you recognise. That tells you what the provider can show now. Keep unsent drafts and local archives safe while the app reconciles its view. A UIDVALIDITY change can occur while the server still contains the same emails.
Read a UID in the context of its folder and lifetime
An IMAP UID is an integer the server assigns to a message in a folder. When the server adds a message, it assigns a UID greater than the UIDs already in use there. An email app can store that identifier to fetch the same message after reconnecting. For that lookup it must know which server account, folder and UIDVALIDITY value the identifier belongs to. Two folders can both contain a UID 84, even under the same account.
In RFC 9051 the folder is called a mailbox. Here, a folder means the IMAP mailbox selected within an account, such as Inbox, Sent or a project folder. UIDVALIDITY belongs to that folder's identifier lifetime. If a server can preserve the existing identifiers, it can keep UIDVALIDITY stable across ordinary sessions. If the mapping can no longer be preserved between sessions, the standard requires an increase so the client can detect the change. A permanently removed message leaves a gap. The old UID remains reserved under that UIDVALIDITY value. RFC 9051, message identifiers
| Value | What it identifies or describes | How to interpret a change |
|---|---|---|
| Folder name | A folder in the account's namespace | Check whether a rename, recreation or different server changed which folder the client opened. |
| UIDVALIDITY | The lifetime of the folder's current UID mapping | A different value means saved UIDs for the previous mapping need to be set aside. |
| UID | A particular message in that folder under that mapping | A UID can appear in other folders or under a fresh UIDVALIDITY. Keep the full context. |
| Message sequence number | A position in the current folder ordered by UID | Expunging a message can shift the positions of every message after it. |
| UIDNEXT | The server's predicted next UID | Within one UIDVALIDITY it advances as messages are added. The numbers can have gaps. |
| Message-ID header | An identifier written into the email's headers | Useful for comparing candidate copies when available. Confirm the messages themselves before acting. |
Picture Inbox with three emails. The server assigns UID 41 to a delivery note, UID 42 to a booking confirmation and UID 47 to a quote. In that state their sequence numbers are 1, 2 and 3. If the delivery note is expunged, the booking confirmation's sequence number becomes 1 and the quote's becomes 2. Their UIDs remain 42 and 47 within the same UIDVALIDITY. Selecting whatever now sits in position 2 would choose the quote. Looking up UID 42 would still select the booking confirmation.
Copying the quote into a folder called Projects creates a destination entry under that folder's UID mapping. The source and destination identifiers can differ. When a supported IMAP copy or move response includes COPYUID, it gives the client the destination UIDVALIDITY and the source and destination UID sets. The client can use that information to update both folder views. A log viewer showing just a numerical UID removes the context you need to interpret the event. RFC 9051, COPYUID response code
Trace what a change does to an offline action
Suppose the IMAP server originally showed Inbox under UIDVALIDITY 610. UID 42 belonged to the booking confirmation. While offline, the app saved an instruction to move that message to Archive. Overnight a restore rebuilt the folder's identifier mapping. The next connection opens Inbox under UIDVALIDITY 740, where UID 42 now belongs to a different message. The operation saved yesterday was for Inbox under 610. Sending it with UID 42 in today's folder could move an unrelated email.
A client can detect this at folder selection. The following example shows two parts of separate sessions. The accompanying IMAP responses are omitted so you can focus on the value being compared.
Saved from the previous session
* OK [UIDVALIDITY 610] UID mapping for Inbox
Received in the current session
* OK [UIDVALIDITY 740] UID mapping for Inbox
The app should stop using the old UID list, build a current one, and keep pending operations tied to those old identifiers out of the new folder. It can look for a way to help the person recover the intended operation after sync. The safer route for an individual mail action is to find the intended message again and confirm its contents and destination before moving it manually. If the app already attempted a move before the disconnect, check both Inbox and Archive first. The earlier action may have reached the server even though the app never received confirmation.
Extend that example to a shared address. A colleague can be looking at current Inbox while your Windows app is recovering its earlier view. If you both move messages to recover a day's filing, coordinate which folders you will check and which actions are still outstanding. A sync conflict over a single folder can otherwise turn into two people filing copies or following up on the same conversation. Use existing subjects, dates and folder locations to agree which items need action. RFC 4549, handling changes in UIDVALIDITY
Narrow down why the identifier mapping changed
Normal arrivals, flag changes and permanent removals can all occur while UIDVALIDITY stays stable. The server has ways to describe those changes within the current mapping. If your issue starts with a missing star or a new message arriving late, first establish whether there was an actual UIDVALIDITY change. A sync warning, on its own, could also come from folder permissions, a connection failure or a problem building the local search index.
A server can have to issue a new value when recreating a folder with a name it used before, when it cannot retain the existing UID information through a restore or when it needs to regenerate identifiers. A migration can keep UIDs and UIDVALIDITY if the new service preserves the mapping and takes over the previous mailbox identity consistently. Whether it did so is a question for the host or migration administrator. Similar folder names, dates and counts tell you about the visible mail and provide only part of that evidence.
| When you saw the change | What to check first | What to keep for follow-up |
|---|---|---|
| Once after a planned migration | Check the destination in webmail and confirm clients use the new endpoint. | Migration time, affected folders and whether historical mail and Sent are visible. |
| Once after a folder was restored or recreated | Compare the restored folder in webmail with known message samples. | Folder name, restoration time and any dates missing from the restored copy. |
| On each reconnect for one folder | Ask the provider whether the folder is repeatedly being rebuilt or lacks persistent UIDs. | Selected folder, several observed values and the times they were returned. |
| Intermittently across several devices | Confirm they connect to the same service and ask the host to check server consistency. | Which clients see each value, the affected account and any known infrastructure change. |
| Only on one PC with stable webmail and another current client | Check the app's sync status and confirm the exact folder it opened. | App version, local sync status and the provider's current folder response if available. |
RFC 9051 describes the unusual case of message stores that cannot persist UIDs between sessions. New identifiers and UIDVALIDITY values can make repeated cache rebuilding necessary. A folder that becomes unstable after a host switch also warrants checking which endpoints clients reach. The observation that values alternate is information for a provider investigation. The client log alone usually cannot establish whether a backend, folder identity or implementation is responsible. RFC 9051, UID persistence
Distinguish a folder rebuild from a search reindex
A local mail store can have several layers. One layer remembers which message identifiers are in each folder. A separate layer may cache headers, bodies and attachments. A search index can extract words and references for fast lookups. The app needs a current identifier map before it can confidently attach old cached information to a message from the server. The index can then catch up with the refreshed view.
After a rebuild, a large folder may show its newest subjects while older results are still missing from local search. Opening a message body online can succeed even if the app has yet to index it. Conversely, an old search hit can linger until a stale index is reconciled. Search for a known recent subject and a known older subject, then look at the actual folder in webmail. If you expected to search the server, verify which account and folder your app queried and whether the provider includes the result.
A sync extension can reduce the work required when the same UID mapping is still valid. CONDSTORE supplies change tracking for metadata such as flags. QRESYNC can let a compatible client catch up on changed or expunged messages after reconnecting. A client using those features checks UIDVALIDITY before relying on the saved state. If the value differs, it needs to discard the cached change cursor and use the current folder descriptors. Support for these extensions depends on the client and the server. RFC 7162, disconnected client synchronisation
The time to rebuild depends on the number and size of messages the app fetches, the depth of its offline settings and the service's response time. Compare progress for the same folder over a few refreshes. If new test messages start appearing and older records gradually become searchable, leave the sync running. Capture the status and exact error time if progress repeatedly stops at the same point or starts over whenever you reopen the app.
Recover mail safely on Windows
Check the provider's copy before changing the profile
Sign in to webmail for the affected account using the provider's normal address. Confirm which folder and device are affected. Look for a recent incoming message, an older one and a sent message if Sent is involved. Check a customised folder if the account recently moved hosts. If the provider has search filters or conversation grouping, open individual messages and confirm the dates and folders you expect.
If important messages are absent from webmail, establish whether they lived in another folder, an old provider account or a local archive. Check the old host if you still have access. Ask the provider which mail folders came across during any restore. Keep the current desktop data available while that investigation is underway. An account removal or bulk folder repair can make a remaining local copy harder to retrieve.
Save local work before refreshing the connection
Check Drafts, Outbox and any folders the app stores only on this computer. Preserve unsent work using the app's supported export or backup route. If a composed message is partly uploaded or in an ambiguous state, check its status and webmail Drafts or Sent before recreating it. If the outgoing server already accepted an earlier send, repeating it can deliver a duplicate.
Record examples of pending mail actions that matter to you, such as three messages you filed just before the account migrated. Include their subject, approximate date and intended folder for your own comparison. Work with the current folder contents after sync to check each operation. A local archive and an independent export can remain useful recovery sources even if the app discards the previous mapping to the online folder.
Let the app complete a normal sync
Reconnect to the network, verify that the app is online and use its normal refresh. Keep the computer awake long enough for the folder to populate. If the client has a supported folder repair command, check whether it rebuilds search, downloads messages again or rewrites server data before using it. Prefer a supported operation scoped to the affected folder once your independent checks are complete.
When webmail shows the mail you expect and the desktop sync is stable, compare a known recent message and an old sample that falls within your download range. Check one read or flagged state and, if relevant, one attachment using the access methods available in your edition. Open a separate server folder to confirm the symptom is limited to the one you identified. In Swftink, if you're checking a message that may fall outside local search, use the connected mailbox's server search when your edition offers it and the mailbox is online. From a combined inbox, select the relevant account first.
Give support a short, sanitised record
Record the app version, Windows version, server hostname, approximate timestamp and affected folder. Send exact UIDVALIDITY values if your app reports them. Include whether the folder refresh completed, whether the warning returned and whether the same messages appear in webmail. Mask addresses or folder names where they reveal private information. Leave out passwords, OAuth tokens and raw message content. A small log excerpt around a folder selection usually gives more context than a screenshot of an empty inbox.
For a hosting provider, mention the date of any migration or restore and ask whether the affected folder preserved its UID mapping. If instability occurs across accounts, give an example of the timing from each affected account through the provider's private support channel. For desktop support, report whether the folder contents looked correct on an independent device and whether the app offered an error or was still indexing past mail.
Check a planned migration with a disposable folder
Create a small test folder at the original host if your plan allows it. Add sample messages of known content. Mark one read, flag a second and include a uniquely named older sample. Open the folder in an authorised test client, let its cache populate and record the identifier values if available. Record the original folder's visible count and any metadata the migration promises to preserve.
After a test migration, open the destination webmail and confirm those samples. Open the folder from a current client and check whether its content and flags match. If testing a client that had synced to the old service, verify it connects to the intended destination and let it reconcile any change. Using disposable mail allows you to test a simple flag change and see exactly which sample the server updates. Keep production profiles and archives available during the test.
For a migration of several folders, sample each type separately. Inbox verifies incoming history. Sent gives you a picture of filed outgoing mail. A nested project folder verifies that the new service and client interpret the folder hierarchy the same way. A local archive in the old client belongs to that app's data and needs its own copy or export. Decide whether people need the archive on the new server and include that work in the migration schedule when they do.
A successful first sync shows that the client can read the mapped folder. Reconnect again after a few ordinary changes and compare a known message by subject and contents. A stable mapping across those reconnections is good evidence that day-to-day sync can resume. Save the test observations with the migration record so you can narrow down any later discrepancy to a folder, a device or a time window.
If you find two folders with the same display name after migration, compare their full locations, sample dates and current contents before checking the identifiers. The new provider might expose an imported copy under a different parent folder. That copy has its own UID mapping. A sync log for it cannot explain missing messages in the original folder. Ask the migration administrator which path the client should use and whether both folders contain material that needs to be preserved. Check missing or unexpected IMAP folders
Know which identifiers you can use to compare messages
A message's Message-ID header applies to the message as formatted for email and often travels with a copy. Two copies in different folders can share it while having different IMAP UIDs. Some messages lack the header, and duplicated or malformed values occur in practice. When you need to verify an original after a rebuild, compare sender, recipients, timestamp and body alongside the header. Keep both copies until you are sure which records you intend to preserve. RFC 5322, identification fields
A useful final check is a fresh test message with a unique subject. Verify it in webmail and the desktop folder, change a flag on that one message, then refresh both views. If that works and samples of older mail are now accessible, the client has a functioning connection and can reconcile at least the tested folder. If old history remains missing in webmail, investigate recovery with the provider or use a verified export. If the history is visible online and the desktop view stays incomplete, compare the app's history settings and give support the observed folder and sync status.