Forcing Mail.app to resynchronise an IMAP folder
The cause was me force quitting Mail.app while it was in the middle of trying to make sense of the multiple huge imap copy/move requests I had given it.
The symptom was that when I clicked on an email title in that folder, a totally different message would open up.
Since all the other folders were fine and each folder in Mail.app is represented on disk as an mbox file, I figured that just that mbox file (and associated index) was corrupted. I didn't want to recreate the whole account in Mail.app since resynching my 3Gb email account would result in a lot of bandwidth (even though it is going over a compressed ssh tunnel).
A bit of poking around the ~/Library/Mail directory shows that each account has a directory named something like "imapUsername@imapHost", which may or may not be the same as your email. Inside that directory, there is a simple folder structure. An imap folder in your account named "FolderName" has a directory called "FolderName.imapmbox". If the imap folder also contains sub folders, there is an additional directory just named "FolderName" that follows the same directory structure. The "FolderName.imapmbox" directory contains an mbox file and a small plist file.
What I hoped would work, and in fact did, is that you can remove any given .imapmbox file (while Mail.app is NOT running) and it will be recreated and synchronised the next time you open Mail.app and visit that folder.
Sweet. It's just a pity that Apple doesn't provide a context menu item called "force re-sync" or something like that. Of course fixing the sorces of crashes that cause corruption would be even better, but you'll never get rid of all bugs, so a re-sync option would be usefull for the advanced punter who doesn't want to go typing rm -fr too often (did you get that Bruce?).
keywords for my American searching friends: resynchronize synchronized
09:16 AM, 15 May 2006 by Mark Aufflick Permalink