Rebuild the Mailbox & Reindex Messages to Fix Common Problems in Mail App for OS X

Aug 1, 2013 - 20 Comments

Mac Mail app icon The Mail app bundled with Mac OS X is an excellent email client, but if you have a giant mailbox that has been in use for a long time you may encounter some peculiar problems with sluggishness, message content issues, and searching irregularities. Usually these issues are of distinct types; search errors where some messages don’t come up in results when you know they should, unusually slow behavior when performing mail searches, or just general mail content problems, where an opened message appears blank, incomplete, corrupt, or is otherwise displayed improperly.

Fortunately these issues are very easy to correct thanks to a two step process of forcibly rebuilding the mailbox, and then forcibly reindexing all messages contained within the OS X Mail app.

Before proceeding, you may wish to consider clearing out the Spam/Junk mail folders contained in Mail app to help speed up both reindexing and rebuilding. Such junkmail housekeeping can become automated with a simple settings adjustment as described in this collection of great tips for Mac Mail.

Rebuilding the Mailbox

Rebuilding a mailbox in Mail for OS X is very simple:

  • Launch Mail app and pull down the Mailbox menu, then choose “Rebuild”

Rebuild Mailbox in Mac Mail app

(If you don’t see the Rebuild option or it is greyed out, close any compose windows and select the inbox in the primary Mail app window)

This rebuild process can take a few minutes, or even an hour or more depending on how large your inbox and sent messages folders are.

An important note: this may cause significant bandwidth use for mailboxes configured with IMAP or Exchange, because the locally stored messages are removed and then redownloaded from the remote mail server. That can make this task unsuitable for users who are connected to the internet using a data capped connection, like a smartphone with hotspot.

Repair & Reindex All Messages in Mail app

You may encounter an alert from Mail app telling you that the mailbox must be repaired, but you can also do this manually. This is particularly helpful if the search functions of the Mail app have become unreliable.

  • Quit out of Mail app and go to the Finder
  • Hit Command+Shift+G and go to the following path:
  • ~/Library/Mail/V2/MailData/

  • Delete every file that begins with “Envelope Index” (optional but recommended: back up these files to the desktop just in case something goes awry)
  • Close the MailData window, then relaunch Mail app to force reindexing

Force reindex Mailbox in Mac Mail app

Like rebuilding the mailbox, the reindexing process can also take a while, depending on how large the mailbox is and how much mail is stored on the computer. Be prepared for a lengthy re-indexation if you have tons (thousands+) of messages in Mail app. When finished, try the search or perform the task that you had issues with before and things should be working as usual again.

These two solutions will fix most common mailbox related issues encountered in OS X Mail, so try them out the next time Mail app is performing strangely. On the mobile side of things, iOS does not have similar forced rebuilding and reindexing options, and thus to resolve similar issues you often have to remove the account from iOS Mail settings and then re-add it to resolve like problems, but that’s a topic for another article.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Mac OS X, Tips & Tricks

20 Comments

» Comments RSS Feed

  1. Paul S G Adams says:

    I have tried your ‘fix’ of deleting files beginning with Envelope to rebuild and re-index my mail but the problem I have discovered remains.

    Some of my local mailboxes are displaying the title and date received but the content therein is blank; I stress that only some of my mailboxes are affected not all – which I find really strange.

    I am sure this has only arisen since my upgrade to Mavericks.

    • Phil W says:

      Same issue as Paul – after moving email to a different mailbox some are fine others lose all content. Tried both fixes to no avail. As an aside the “rebuild” function seems to do nothing – when I select it nothing happens at all.

  2. Dean says:

    Thank you for listing the manual option in deleting the “Envelope” files. This was particularly helpful today as Mail froze while loading in Yosemite (Mac OS X 10.10) and wouldn’t launch after a force quit.

  3. Mike Simmons says:

    I’m a bit baffled here because I can’t find the MailDAta folder – I just get a not found message – running 10.6.8 – could that be it?

  4. Nivaldo Junior says:

    Hi, I have recently installed Yosemite from scratch. I used to have some old e-mail on my Mac not on the server and I backup them by copying the folder ~/Library/Mail/V2/Mailboxes witch had a series of files like e-mails 2009.mbox

    I did the clean install and the I’ve copied the contents of the backup to the ~/Library/Mail/V2/Mailboxes on the new install.

    The problem is that the mailboxes show on mail app but they have no e-mail inside.

    After this I’ve tried to import the mailboxes to mail. The process finishes very quickly with no errors, but no mail shows on mail app.

    Please help, I really need this e-mail back.

    • sinhg says:

      i have the same issue as Nivaldo, can someone help .

    • Zhang Huan says:

      Same problem. I upgraded to Yosemite, and found some mail messages’s index are incorrect. Then I rebuild the mail box. But the rebuild never ends, and even I copy back the mail box from my time machine backups. The mail never show on Mail.app.

      Some body help.

  5. Jamie Vans says:

    This fix seems to have worked for me (MacBook Air, Yosemite), thank you. It was driving me mad!!

  6. M Herman says:

    The second fix –reindexing (deleting the envelop files) using the library stopped mac mail from crashing after a Yosemite install–I had 70,000 messages stored in IMAP

  7. M Herman says:

    Oh I spoke too soon, the crashes are back–it must be something that gets back into your program as you use mail

  8. Wolfgang says:

    perfect. apple mail works again. thank you!!!

  9. Randy says:

    Thanks for this one. Had many of the symptoms (Yosemite) and have an enormous amount of email so was reluctant to do a rebuild that would re-download all data.

    Tried the reindexing and wow! Lingering fetch processes are now gone and everything is much snappier. I suspect my searches will now be more accurate too. Based on my experience, I’d recommend this (second step, reindexing) to anyone looking to pep up their Mail. Only took about 10 minutes to reindex something like 140,000 emails.

    Gratitude.

  10. Stuart says:

    I have a corrupted Envelope Index file and cannot backup my iMAC (SuperDuper stops when it come to that file). Cannot copy the file either to another drive, only move to Trash

    When I move the Envelope Index and the two other Envelope Index files to Trash and then restart Mail (osx 10.9.5), it asks if I wish to implement a new MAIL and to import my old mails.

    Is this what the previous correspondents did to recreate the indexes, or am I missing something ? I really don’t want to lose my mails,

    thanks for your advice,

    Stuart

  11. Steve says:

    Reindexing fixed the problem of bogus numbers in my Flagged Mail folder. Now however, I cannot open more than one email at a time no matter which folder I choose.

    Advice?
    Thanks,
    Steve

    • Steve says:

      Clarification: double-clicking when multiple emails are selected does not open any of them. However, cmd-o does…

      Steve

  12. Greg Raven says:

    Worked for me. Thanks! Just recovered thousands of e-mails that had disappeared from the “On My Mac” folder that was holding them.

  13. pheski says:

    I am currently trying to re-index with the instructions here. I get the expected ‘preparing to import messages’ message, and I am expecting it to take a very long time, as I have too many mailboxes and too much mail.

    My question is: Should Force Quit say Mail is not responding during this? Activity Monitor says Mail is not responding but also shows changes in % CPU time, and threads, which suggests that something is happening and that I should simply be patient – that the ‘not responding’ is what I should expect to see while Mail is re-indexing.

    Confirmation that this is expected would make my day better….

    P

  14. pheski says:

    OK, it appears that what happens is:

    *ForceQuit and Activity monitor say Mail not responding.

    *After a long time, the three Envelope Index files in ~Library/Mail/V2/MailData ultimately stop changing and Activity Monitor stops showing any CPU use

    *Then one needs to force quit Mail and restart it. Perhaps more than once (It took me 3 times.)

    *Then there is a new and accurate index and Mail is noticeably faster.

    P

  15. Sandy says:

    Re-indexed with no problem as per your instructions, but The problem remains with Yosemite: the mailboxes show on mail app but they have no e-mail inside. I get a gray “no message selected” message in the main box of the viewer window.

    I can send and receive mail, I just can’t see it! Is there a proper fix for this yet??

    Many thanks…

    Sandy

  16. victoria says:

    The Mail search function suddenly stopped working at all today.
    I did both delete envelop files and Rebuild but the problem remains!

    Can anyone help me out?

    Thanks!!!

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates