Apple

How to recover email from Apple Mail corruption

Regaining access to lost or corrupted Apple Mail is a common task for admins. From simple rebuilds to complex recovery operations, here are five levels of fixes you may be called on to make.

There are many applications that are used enterprise-wide for a number of different industries. But few are as mission-critical and ubiquitous as email. The instant gratification of exchanging information in such an effortless way is taken for granted until something goes wrong. One never truly feels the sting of helplessness in such a way as when email access is lost, or more specifically, access to saved email messages is not immediately available due to loss or corruption. There may even be legal ramifications depending on the laws that govern your particular employer or industry, or those enforced by state or country.

Before I continue, I'd like to point out that try as I might, I couldn't find any concrete documentation regarding the limitations of Apple Mail with respect to maximum number of messages, folder sizes, etc. With that said, Mail should be just as responsive with 10GBs of data as it would be with 10MBs - until the day it's not! That's just how quickly problems like this can creep up, so if you notice Mail slow to load, crashing frequently, or even spiraling the color wheel to no end, it may be time to take counter-measures.

The solutions outlined below range from entry-level to extreme-case scenarios. The amount of time and storage space needed to recover from data loss or corruption will depend solely on the number of email messages stored within the Mail.app folders.

DEFCON V: Rebuild

  • Open Apple Mail.
  • Select the folder(s) you wish to include in the rebuild process.
  • Click on Mailbox | Rebuild.

Figure A

Simple as that! This offers a simple way to rebuild the various mail folders, removing any stray files cluttering up the mailbox folders.

DEFCON IV: Restoring preferences

  1. Quit Apple Mail.
  2. Navigate to the following directory: ~/Library/Containers/com.apple.mail/Data/Library/Preferences (OS X 10.7+)* and drag the following file to the Desktop: com.apple.mail.plist (Figure B)
  3. Open Apple Mail to allow the application to recreate a new preferences file.

Figure B

Restoring preferences is not always a sure-fire solution (and can sometimes cause more trouble than it solves, if the wrong files are removed). But it's almost always worth a try since sometimes the only solution is OS X recreating the .plist file to get things humming along and have all email messages showing up again.

*Note: For OS X (10.4-10.6), the proper directory is ~/Library/Preferences.

DEFCON III: Archiving (Exporting Mailboxes)

  1. Open Apple Mail.
  2. Select a folder to create an archive from. If selecting a root folder, all nested directories will also be archived automatically as well. *
  3. Right-click (or control+click) and select Export Mailbox from the context menu. (Figure C)
  4. Select the destination for the exported mailbox folder(s) and select Choose. (Figure D)
  5. Optionally, double-check the newly created .MBOX file(s) to verify the entire file structure selected within Mail was properly exported. Each folder selected in Mail.app will be represented by its own .mbox file in the hierarchy. (Figure E)

Archiving offers a way of exporting data from Mail to an alternate location, in the hopes of removing it entirely from Mail.app to free up space or just perform some cleaning up. This method allows one to keep the emails for future perusal without it impacting negatively on Mail's daily usage.

*Note: While it is possible to select multiple folders to export, bear in mind that when working with large amounts of data or many folders or folders nested within folders, keeping track of which .mbox files contain specific messages can become dizzying. Instead, focus on keeping folders to be exported grouped together, similar to the Apple Mail structure for the sake of simplicity. This way, if it's necessary to revisit these files later to recover a missing message, it won't be so complicated to find, plus, I find it minimizes the possibility of merging corrupt data with non-corrupt sets.

DEFCON II: Recovery (Import Mailbox [.mbox] Folder)

  1. Quit Apple Mail.
  2. Identify the location of the mailbox folders to be imported (either locally or from external backup/Time Machine). If local, the directory is: ~/Library/Mail/V2
  3. Located within the folder structure will be a root folder for each email account that has been added to Apple Mail. By navigating down one level, you will find the root mailbox folder for the directory hierarchy. Double-clicking the .mbox file will allow you to drill-down to locate the mailbox folder you wish to restore.
  4. After the .mbox file to be restored has been identified, open Apple Mail and click on File | Import Mailboxes... (Figure F)
  5. A wizard will open to guide you through the process. Select Apple Mail instead of Files in mbox format for the best chance at compatibility importing your files and select continue. (Figure G)
  6. You'll be prompted to locate the mbox file (or root folder containing mbox files, if there are multiple files you wish to import). Navigate to the location identified in step #3 and select choose. (Figure H)
  7. Once the process has completed successfully, you'll see a confirmation screen informing you that the imported files can be found in the Import folder under On My Mac. (Figure I)
  8. A successful mailbox folder import will be an exact duplicate of the files/folders from the locally stored mbox folder or external backup mbox file. (Figure J)

This process can be one of the most nerve wracking when it comes to dealing with importing mailbox folders or worse -- the last stand between restoring an end-user's months, years or even decades worth of emails and complete loss of email.*

*Note: While most organizations still rely on the venerable POP3 protocol to retrieve email, it must really be noted that the IMAP protocol eliminates a lot of this from occurring at the desktop-level with its built-in synchronization features. Going somewhat off-topic, this is a good time to reiterate the importance of timely backups for all of ones important data. However, in the event that backups of email messages are not possible or expressly prohibited, an IMAP-enabled account could simply be removed from Mail.app and recreated, thus triggering the sync upon establishing a connection with the email server.

DEFCON I: Third-party email management application

This is a worst-case scenario for recovering from severe email corruption, brought on by any combination of the previous levels above, combined with the sheer volume of messages contained in Apple Mail. We're not talking 10-20GBs here, but more like 80GBs+ of emails and attachments. If the size of the mailbox was not difficult enough to manage on its own, when you sprinkle in file corruption, missing data, and an application that is literally paralyzed for 20-30 minutes before opening the main window, you have a recipe for disaster!

By the time Apple Mail gets to this level, some if not all, of those symptoms would have set in, making resolving the matter something else entirely. How do you battle this beast and live to tell the tale? With careful planning, exercising caution, and a little help from a third-party Email Management application.

I researched several applications that would serve well to help get Mail.app's mailbox folders to manageable levels. Here are a few that stood out:

  • EagleFiler from C-Command Software, which is billed as a way to "organize, search, and archive your e-mail, Web pages, files, and miscellaneous scraps of information" by the developers. Its general purpose is to archive your data - all of it in one easy-to-use app with many hooks to popular add-on applications.
  • DEVONthink Pro Office from DEVONtechnologies is next on the list. This application is full-featured for all manner of office related duties and it's gorgeous in its execution. However, based on personal testimonies, ease of use, and integration, I've personally implemented...
  • MailSteward from pubblog.com. MailSteward does one thing only and it does it well -- archive email! Either manually and/or based on an automated schedule, it creates a database and proceeds to copy (not move) your email from Apple Mail onto the database, complete with attachments and all! Once it's completed, the newly archived emails are safe to delete from Mail.app thereby eliminating the huge processing load brought on by the GBs of messages stored. Since MailSteward works from a local database, information is indexed and fully searchable making finding messages by a number of search queries effortless. Also, attachments are included alongside the original messages as well for ease of use.

Just to be clear, I'm not advocating a specific app over the others. The bottom line remains that each scenario will be a unique issue all unto itself due to the sensitive nuances of the user's email and what resources are available to you. While similarities exist and many of the troubleshooting tips above will work, you'll find that they won't all be a right fit to resolve the problem. Ultimately, at this level, the program that works best is the one that fills a specific need most completely. Most offer a free trial to test out which will allow for the best chance of recovery.

However, the best tools in overcoming email corruption (or preventing a catastrophic loss) are a good, recent backup of the data, caution, and lots of patience. Once data is backed up and in a recoverable state, safety measures can be implemented to minimize the possibility of a repeat failure. A secondary backup archiving solution, while completely optional, never hurt anyone either.

About

Jesus Vigo is a Network Administrator by day and owner of Mac|Jesus, LLC, specializing in Mac and Windows integration and providing solutions to small- and medium-size businesses. He brings 15 years of experience and multiple certifications from seve...

6 comments
Topcopy
Topcopy

This is a small problem compared to most major disasters, but is extremely disturbing, nonetheless. I just selected and dragged about eight emails from my inbox in Mac mail (7.1) into a different mailbox folder. Now they are no longer in either place, and also not in either my trash or my Mail trash. They don't show up in a search of Mail or in a Spotlight search of my laptop. They're just gone. Is their any hope of getting them back? (Of course this happened during one of the frequent times when my Time Capsule was down.)  FYI I'm on a MacBook Pro running 10.9.1.

hvanbrug
hvanbrug

I wonder if you've run into this problem before / know how to fix it. I have an email account that is no longer valid. When I try to remove it or even just disable it, it starts replicating itself at a rate of about 10 per second until I force mail to quit. When I restart Mail all the duplicates of that account are still there, and if I try to disable or remove any of them the process starts over again. I have tried to manually remove them by just deleting files willy-nilly, but I have never been able to get rid of that account fully. I hope you know of a possible solution.

Gisabun
Gisabun

Something on a Mac gets corrupt? Say it ain't so. :-)

themacjesus
themacjesus

@hvanbrug That's a difficult situation, but one I've seen before. The tough part is what exactly is causing the replication issue. It typically is Apple Mail (or some corruption located within the mailbox files). I'd recommend trying DEFCON V and IV as detailed above.

Hope this helps to resolve the duplicate mail issues @hvanbrug

themacjesus
themacjesus

Apple (contrary to popular belief) is prone to some of the same afflictions as its computer cousins ;)

HAL 9000
HAL 9000 moderator

This is talking about Enterprise Wide so obviously it's the Exchange Server that is the problem everyone knows that Apple is Perfect after all they tell us so themselves so it must be true. :^0 Col [/maniacal laughter]