If you have recently lost a large number of messages in OS X Mail, then provided you have a Time Machine backup of your system, you will have three options for restoring your messages. The first approach, since you can access Time Machine backups from within Mail, is to go to your mailbox in Mail and then invoke Time Machine and attempt to find and restore your messages from within the Mail interface; however, this is only practical for recovering a few messages, and in some cases this approach may simply not work.
The second option is to restore your entire system to a prior backup, which again is somewhat impractical since you might lose some third-party application registrations, and take the time to perform the full system restore. This being the case, the third and perhaps most straightforward approach for recovering large amounts of lost e-mail is to restore your messages manually in the Finder using Time Machine.
Since Mail keeps all of its data in the Macintosh HD > username > Library > Mail folder, you might consider going to your user account’s library (by holding the Option key and choosing Library from the Go menu in the Finder), and then invoking Time Machine from within the Finder to restore a recent backup of the “Mail” folder Time Machine; however, you will likely find that even though you can view this folder in Time Machine, the “Restore” button will not be available when choosing this folder.
- Open your Time Machine disk, and then go to the backup of your account’s Library folder:
Backups.backupdb > ComputerName > Latest > Macintosh HD > Users > username > Library
Note that the “latest” folder here will select your most recent backup, but you can choose from any of the available backup instances, if you think one might be more relevant for the data you are trying to restore.
- Select your Mail folder and press Command-C to copy a reference to it.
- Go to the Library folder in your active user account, and rename the folder called Mail to something like “Mail-old.” You can also right-click the folder and archive (compress) it as a zip file.
- Press Shift-Option-Command-V to paste the previously copied folder exactly as-is, and preserve all permissions. Authenticate when prompted.
Since this folder contains your Mail messages, you might think this is all that’s needed; however, if you try to open Mail immediately after copying the Mail folder from your backup, you may see the following error message in Mail:
“Mail can’t open because you don’t have the necessary permissions to change the folder where it saves information.”
This happens because Time Machine appends hidden permissions settings called ACLs (access control lists) to files, similar to the following, which help prevent them from being modified on the backup drive (see that they “deny” access for “everyone”). When you copied the files from the Time Machine drive, you did so by preserving all permissions settings, including these ACLs.:
0: group:everyone deny write,delete,append,writeattr,writeextattr,chown 0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown
This might be confusing because despite the error that Mail gives you, if you get information on the Mail folder you will see your account has full Read and Write access to it; however, this is because the Finder only shows you the older and simpler “POSIX” unix permissions, and does not show much (if anything) about ACL details.
For Mail to properly read from this folder, once it is copied you will need to strip off these ACLs from it and all items contained in it, which can be done by opening the Terminal utility (in the Applications > Utilities folder) and running the following command (copy and paste it to the Terminal to run it):
chmod -R -N ~/Library/Mail
With this step complete, your last step is to restore your old Mail preferences file, which contains the information about the accounts and mailboxes you had configured when the backup of your Mail folder was created.
Restoring this file will ensure Mail will find all of the messages you recovered, and not overlook any mailboxes. For instance, if your loss was from deleting some of your mailboxes (or the entire account, and all of its mailboxes), then your current preference settings will not point to these lost mailboxes, so even if you restore the data, Mail will not look for it. On the other hand, the old preferences file will tell Mail that these mailboxes exists.
Restoring the preference file can be done with the following steps:
- Go back to the same Library folder on your Time Machine disk, and then go to the following directory within it:
Containers > com.apple.mail > Data > Library > Preferences
- Locate the file called “com.apple.mail.plist,” and then select it and press Command-C to copy a reference to it.
- Go to your user account’s Library folder, and then to the same Containers > com.apple.mail > Data > Library > Preferences folder within it.
- Press Command-V to paste (and thereby copy) the preferences file to this folder. Be sure to replace the old one that you have in there.
With these steps done, you can now launch Mail, and when you do so, the program will read from the restored preferences file to load details about the prior Mail accounts and mailboxes, and then be able to associate them with the contents of the restored Mail folder on your hard drive.
Mail will likely perform an import routine on your restored mail, but this is simply it re-indexing your files. After this is done, you should have the full mailbox organization as you had before you lost your messages, so your lost messages should be somewhere in your mailboxes. If everything checks out, you can then go back to your user library and delete the unused Mail folder (the one you had renamed to “Mail-old”), or the archived zip file that you created of it.
I may be missing something in your narrative, but I think this process might not save any ‘new’ messages from a POP type account. Any POP messages _after_ the Time Machine restored collection _will_ be in the “Mail-old” file, but retrieving those was not discussed.
Perhaps Mail is smarter than I am, certainly a possibility! 😉 However, I suspect it may require some direct/manual copying and pasting, perhaps even re-mailing(?) those POP messages to get them back into the Restored collection.
In most cases POP messages will remain on the server for a short while, and not be immediately deleted, so they should be re-retrieved when you open Mail again. In addition, I don’t recommend this for recovering long-lost e-mails, but rather only in instances where some action you just took resulted in the loss of a lot of emails.
However, this is why preserving the current Mail folder is important, and also that you do not delete it until everything checks out to be there. In addition, if you have only lost a few newer e-mails, then you can get them back from Time Machine within Mail.
Curious as to why you could not just do a regular command-v paste of the ~/Library/Mail folder as opposed to the Shift-Option-Command-V method you described . Wouldn’t that negate the permissions problems?
Thanks so much, I just went thru the process and worked very well! I thought I lost all my emails after making the mistake of updating my existing IMAP account with new gmail IMAP, that erased all my old messages, so I followed your instructions and got them back, thanks again!!
Is there a you tube that takes us through these steps? Thank you so much.
Thanks for this posting. Unfortunately it didn’t work in my case. After I went through all the steps and opened mail, it seems like all the content of the Library > Mail folder gets removed.
Don’t know how relevant is this, but I’m trying to restore my emails from a backup I made ~2 years ago. Are these steps the same even if a different OS version was used in the Time Machine?
do everything he said but with your computer offline. When you restart Apple Mail you should be able to see all messages, restored.
Select the folders you want to keep (those containing the deleted messages), and go to Mailbox – Export Mailbox. Save the file on the desktop or wherever convenient for you.
Then reconnect the computer to internet and let all your messages disappear again.
Go to File – Import Mailboxes.
Select the previously exported file and let it import it.. you should have everything back again under the On My Mac – Import – mbox folder.
Select all, mark as read, move them to the destination folder (should be the same one which contained all the messages you deleted by mistake) and you should be up and running again!
Thank you very much for this tutorial. I really appreciate it!
I having difficulty to get started with this procedure because when I follow the path as you have written, (Backups.backupdb > ComputerName > Latest > Macintosh HD > Users > username > Library) there is no Library folder within the username. There are only the following folders within the username folder: Applications, Desktop, Documents, Downloads, Dropbox, Google Drive, Movies, Music, Pictures & Public.
In the Macintosh HD Folder, there is a Library Folder. However it does not contain a Mail Folder either.
I do know that my emails are stored somewhere because if I enter Time Machine from within the Mail app of the computer which had originally created the backup, they can be seen in the Star Wars reminiscent display of Time Machine. However, as you had written in the beginning of your article, restoring the mails that way simply did not work as not all of them were recovered. (viewed yes, recovered no)
My intention is to re format the computer which had created the backup and once I do, I simply do not trust that Time Machine will restore all emails. Therefore, I would like to achieve it in a manual way as you have instructed. Unfortunately I can not get past the first step for the reason I have described above.
I would greatly appreciate some help with this.
As a side note, I have read that it is possible to browse a Time Machine backup disk from a computer which did not create it by clicking on Time Machine and pressing the alt key. This gives you the option to “Browse other backup disks” Although I am being given the option to do so, this option does not work either.
While the concept of Time Machine seems like a great one, it seems that I can not trust it to perform the basic tasks for which it was created.
Again, I would appreciate some help.
Sounds like you may have added your user Library to the “Exclude list in the Time Machine Pref Panel, or something else did. Open that Pref Panel, click the “Options…” button and check the list there. I suppose it’s possible that you are backing up another user account and added the “Library” of your Admin account accidentally to the “Exclude” list?
I have the same problem that Mark described and I didn’t exclude any folder from the options in TM. Is there any chance to recover my Library folder? or I lost all my mails because of this failure?Is the first time that I used the TM instead the Carbon copy and very worried about. Does anyone knows how to solve this? Thanks
I tried all the steps but still getting the permissions error message when I try to relaunch mail…:(
I have the exact same problem as @Mark (no “Library” in the username accounts)…can’t find a file with the word Mail in it anywhere. @xAirbusdriver, there is nothing excluded from backup in the Options folder (other than the backup drive).
OS X Yosemite 10.10.2, MBP late 2013 model.
Would really appreciate any help – Mail just lost all my emails, was able to rebuild the ones that were still on the mail server, but had a large old account that was no longer on a server. Seems very odd to me that there’s not a way to find and reconnect the emails right on the machine (I’m sure they’re still there, just not recognized by Mail) but all the things I see say to restore from Time Machine.
To see the “Library” of your user account:
1. Open a Finder window if one is not open
2. Select the “Go” menu (click once)
3. Press and hold the ‘option’ key
4. Just below the “Home” item there should now appear a new item called “Library”
5. Select that (Library) item and it will open a new Finder window displaying the Library directory for that user.
To keep that Library available, without the Go / Option key / Select ‘dance’, simply click and hold the “Library” icon shown in the Path bar, to the Side Bar of the open Finder window. If you don’t see a Path Bar, click the View menu and select the “Show Path Bar” item.
Hope this helps, at least to find/see/use the users Library. 😉
Thanks @Airbusdriver, much appreciated. I had found that but what I can’t seem to make it do is go to the library on the backup drive :-(. It does however open the Library on my main Mac, which is good. By laboriously searching through there, I have indeed confirmed that those old emails are at least partially there (which probably means all there). I just don’t know how to connect them to Mail.
Other things I have read about restoring lost mail accounts tell you to go through Time Machine (rather than there being some sort of a “reconnect” facility on the Mac itself)…hence the dilemma with not being able to access the Library on the backup drive.
So appreciate your help and speedy reply!
Thanks! It helped after my MacBook Pro broke down and received a loan machine from the local iStore which I used during the repair of mine. Since the new TimeMachine backup file just did not want to work?!?!?! with my machine, I had to do the restore manually, as written above.
Thanks, good article. I had completed lost all emails on both Apple mail and web server / host. Following your article I managed to copy all emails back but then Apple Mail sync’d with web server / host and effectively deleted them all again (i use a google mail account) so back to square one!
Hi Jeremy, see my reply above. It can be solved 😉
Hm – I’m on Snow Leopard, and there is no directory in my Library called “Containers.” Also, cmd-opt-shift-paste didn’t work, and I had to select just plain Paste from the Finder’s File menu.
Worked perfectly, Time Machine allowed me to Restore and that was it. Pure Bliss to see my mailboxes full again like they were yesterday!!!!!!!!!!
Thanks so much!!!!!!!!!!!
On OS 10.10.5. I thought I was going along fine and was so excited to be able to restore all the emails that used to be in my folders that disappeared 3 weeks ago. But when I got to “Containers > com.apple.mail > Data > Library > Preferences”, I got stuck. I don’t have that under “Containers”. There is “Containers > com.apple.Preview > Container.plist” or “Containers > com.apple.TextEdit”, or “Containers > com.sharpened.FileViewer”. There is “Data > Library > Preferences” under each of the 3 “Containers” but none have “com.apple.mail.plist”.
I don’t know where to go now or how to undo this, which I am assuming I would need to do if I can’t proceed. Please help me out with this. Thanks!
I searched again, using Spotlight and going through files that would seems like they might have com.apple.mail.plist but I can not find it anywhere! Can someone please direct me to where I need to look for it, or what the next step is? I am stuck! Thanks.
First, I’m a little confused about where you are searching; in Time Machine or your local drive(s)?
You should be looking in your Home folder Library. There are actually three different folders named “Library”, but the one you want is in your home folder. The easiest way to get there is to look for the little “house” icon in the side bar of an open Finder window. Click on that and look for a folder icon labeled “Library”.
Do you have the Containers/com.apple.mail/Data path there? If not, what do you have?
Secondly, with a Finder window as stated above, you should now “Enter Time Machine”. That will get you started in the basic area of the back up. From the ‘time line’ on the right-hand side of the screen, select a date that is at least a few months back. Do you see the Containers/com.app.e.mail path yet? If not, try going back a few more months. Please let us know if you can find this path in Time Machine.
This procedure worked perfectly for me in Mavericks. I had to only make the Library visible before making a backup (chflags nohidden ~/Library) – to be executed in Terminal.
However it doesn’t work in El Capitan. How to import all messages and accounts to El Capitan from a backup made in Mavericks?