How can I force Apple Mail to COMPLETELY refresh an IMAP account?

I have a Gmail account that is configured on three different Macs, let's call them Home, Work, and MacBook. Home and MacBook are on iCloud, Work is not, and MacBook is the one experiencing the issue.

No matter what I seem to do, Apple Mail on the MacBook, for only this Gmail account, displays no messages in any folder, and indicates two unread messages in the inbox. Home and Work display the same account correctly, with an accurate reflection of the inbox and messages contained in other folders.

Things I have tried:

  • Synchronize
  • Rebuild
  • Disable account, quit, remove ~/Library/Mail/V2/[email protected] folder, then restart
  • Removed the keychain items for the account from iCloud, remove folder above

Each time, the account comes back with two unread messages out of zero. The Account Info screen shows accurate numbers for everything except the "Sent Mail" folder (though nothing in any folder displays). In experimenting with enabling and disabling IMAP for labels within Gmail, I have seen the item for the "Sent Mail" folder in Account Info display with the correct number of messages, but a title of "Sent Mail" does not exist. Very odd. Sorry I don't have a screenshot of that.

Any ideas?


I'm not sure if this will work for everyone, but I was able to resolve the issue in two parts. To get messages to display properly for all folders on the account, I needed disable/remove the account from iCloud so that it was no longer being synced. Then I removed the mailbox folder described in the question, and added it locally to the MacBook.

After the folders were displaying properly, the index was still a little messed up in that the inbox was displaying an unread count that didn't exist.

To get rid of this, I had to rebuild the full index -- this appears to be different from the Rebuild function that exists in the Mailbox menu, and is more similar to what happens when you open an upgraded version of mail for the first time.

  1. Quit Mail
  2. Navigate to ~/Library/Mail/V2/MailData
  3. Delete any file that starts with "Envelope Index"
  4. Start Mail
  5. Follow prompts to allow Mail to rebuild the index -- this may take a few restarts of the app.

You are on the right track with cleaning things "like an animal" in ~/Library, but there are some downsides to this.

The first thing to do is to make sure it's really not a problem with Apple Mail and Gmail server settings. I would make a new user account on the problematic Mac and set up just that mail account. Your theory that the MacBook is the problem is most likely, but what if both other Macs are corrupt and the MacBook is actually getting what Gmail is sending out (albeit Apple Mail is interpreting those bits wrongly).

If I were to mess in ~/Library, I'd do the following:

  • Make a good backup of my Mac (time machine or other)

  • Zip up Mail Downloads - deleting the mailbox data will leave orphan downloads, so I'll need to sort those later.

  • Quit mail and disable all mail accounts in the Internet Accounts pane of system preferences (uncheck them)

  • Move the following directories and files to trash.

~/Library/Mail
~/Library/Containers/com.apple.mail
~/Library/Containers/com.apple.MailServiceAgent
~/Library/Preferences/com.apple.mail-shared.plist

  • Reboot and empty trash / reverify that the above files are really gone.

  • Delete and re-add that one gmail account to Internet Accounts from System Preferences