September 25, 2015
Copyright (C) 2015 Tony Lima. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.
Disclaimer: I have followed this procedure myself and successfully restored Mac Mail. However, this is no guarantee that the process will work for you. Be careful, go slowly, and if something happens that you don’t expect, contact me before you go any further. All contents contained in this document are presented as-is with no implied or explicit warranty of their usefulness. If you use this information, you bear all responsibility for any and all damages that may occur. My Macbook Pro is a 2009 model with 8 gb memory, OS X 10.10.5, and Mail 8.2 (2104).
For the past few months I’ve been trying to get the Internet Accounts Preferences pane to open.
After trying one tip I managed to trash my mail database. It took me about a week to straighten it out. The purpose of this guide is to show you (a) how I got in trouble and (b) how I fixed it. This procedure is not for rookies. If you’ve never used Terminal before, find someone who knows a bit more about the OS X environment to give you a hand. (If you’re in the greater San Jose, CA area I’ll make a housecall. But my services are not cheap.)
Before you do anything else, make sure you have a current Time Machine backup. This can save you if things go badly wrong. Better yet, make two backups. Once you’ve done that you’re ready for Mac Mail disaster recovery.
Diagnosing the Problem
Here are the symptoms I was experiencing with Mail. It started slowly. Often I had to force quit one or two times after first launching it. And the contents of both mailboxes and “On My Mac” folders was not correct. And, of course, the initial problem was that the Internet Accounts Preferences pane would not open. For what it’s worth, that pane still won’t open. (I almost typed “Internet Accounts Preferences pain”– that gives you some idea of what I’ve gone through.)
Here’s what you’ll need:
- Time Machine backups going back to before your mail got trashed, preferably on some sort of external hard drive. We back up our Macs to our QNAP TS419 II network-attached unit.
- It’s helpful to have a second external hard drive to make backup copies of files you will delete during this process. If you use Time Capsule for your backups this is a requirement. Our QNAP has a Time Machine partition. The rest is used for Windows backups, file server, web server, and a few other items. In the Finder windows below you’ll see SAMSUNG 2tb. That’s a two terabyte hard drive. We have several more left over from the last upgrade of our QNAP.
- Patience and willingness to work slowly and carefully.
Whatever you do, be very careful not to delete anything from Time Machine.
In the Finder windows shown below some items are blurred. This is my computer so, naturally, there are some personal items I’d rather not share.
Step 1: Show Hidden Files and Folders
To make life easy, show the hidden files and folders. One of those hidden folders is ~/Library. You’re going to spend a lot of time there. Open Terminal, wait for the prompt to appear, then copy and paste this into the window:
defaults write com.apple.finder AppleShowAllFiles YES
This is what you should see in Finder now:
You should now see the Library folder in the left navigation pane of Finder windows.
If you want to hide the files later, the command is kind of obvious:
defaults write com.apple.finder AppleShowAllFiles NO
The website recommends rebooting after hiding the hidden files. I didn’t do any research into whether that is necessary. And Finder is back to its default state:
Step 2: Find the Time Machine Backup You Want
From the Applications folder, launch Time Machine. Do not launch the Time Machine in System Preferences.
Here’s what you’ll see. Well, almost. Capturing the screen when Time Machine is launched is, um, tricky.
You are looking at the complete history of your backups. Use the arrows to the right of the Finder-looking windows to navigate back and forth in time. (If the arrows don’t work you can click the title bar of one of the backups and use trial-and-error to find what you’re looking for.) The trick is to keep an eye on the bottom or title bar of the window. That’s where Time Machine tells you the day and time of the backup you’re looking at. (The screen cap below was the best I could do. In fact, if you wait a minute, the window will populate with the data you’re looking for. And, again, the screen capture was not entirely successful.)
Many people don’t know that you can restore almost any element from a Time Machine backup. But first you need to find the last “good” backup. When did Mac Mail really begin to fail? You’ll want a backup from the day before that date.
Once you’ve figured out that date, find the Time Machine backup in the window shown above. Be patient — depending on the location of your backups and their size, populating the window can take several minutes.
Do not restore anything at this point!! All you’re doing is finding the backup you will use.
By default Time Machine puts you in the window from which it was launched (usually Applications). That’s not what you want. Click Library in the left navigation pane then scroll up or down until you see the Mail and Mail Downloads folders. Click around in those folders to make sure there’s actually data.
Then click the Cancel button to close Time Machine.
Step 3: Navigate to ~/Library/Mail on Your Mac
The ~ is a UNIX shortcut for Macintosh HD/Users/Tony (or whatever your user name is).
Next you need to open the Library folder. If you’re lucky that folder is in the left navigation pane. Just click it. If the folder isn’t there, scroll up and down in the left navigation pane until you see your user name. Click it. (If you can’t find it, start at Macintosh HD and drill down as shown in the previous paragraph.) (You may need to click the ♦ to the left of Library to show the subfolders. As far as I can tell, this is another process that can be slow if you just double-click Library.)
Once you have the Library folder open, scroll down until you see the Mail and Mail Downloads folders. Select both. Drag them to an external hard drive. Then go get some coffee. If you’ve been using Mail for more than a few years these folders will be pretty big.
Again, after the folders are copied check the hard drive to be sure the data actually transferred. If you’re really paranoid (and you should be), make a second copy on a high-capacity memory thumb or a different external drive. Paranoia is good because what you will do next is scary.
Step 4: Delete the Mail and Mail Downloads Folders
Drag each to the Trash. Empty the Trash. (I warned you this would be scary.)
Step 5: Restore from the Time Machine Backup
Launch Time Machine. Find the backup you want. Select both the Mail and Mail Downloads folders. (Click while pressing the ⌘ key to select multiple folders.) Click the Restore button.
Time Machine knows where to put those files. Again, be patient. This can take five or ten minutes, possibly longer.
Step 6: Set Up Mail
Before you do this, you need to disconnect from your LAN, the internet, and everything else. You want a clear air gap between your Mac and the rest of the world.
Turn off WiFi and Bluetooth in the Network Preferences pane of System Preferences. Unplug the Ethernet cable.
Got your Mac isolated? Launch Mail. Believe it or not, everything should load and Mail should be restored to its pristine state before you screwed everything up.
This article is titled “Disaster Recovery.” Be careful, make regular backups and have faith in Time Machine.
 See https://discussions.apple.com/thread/5483892 and http://www.macworld.co.uk/how-to/mac-software/how-show-hidden-files-in-mac-os-x-finder-3520878/. If you visit the latter site, do not use the killall Finder command.