Apple’s Mail on OSX has a really nice feature called Smart Mailboxes. this feature creates a folder in which all mails that fit a specific set of conditions.

I have several of these Smart Mailboxes. One of them shows all messages that contain ‘smart home’ somewhere in the message and are still unread.

"Smart

But once in a while my smart mailboxes show ghost mails. Mails that I know I have read still show up in the smart mailbox.

The internet contains various solutions for this problem, from deleting the e-mail account from your Mac to removing files from the mail folders.

Strangely none of these options looked like very promising and secure ways to retrieve just that. Besides the risk in loosing mail it didn’t sound like a solution, but more fixing the problem ‘quick ‘n dirty’.

After my long search I finally came across a post in an Apple related forum that pointed me to Spotlight indexing.

Since Spotlight indexing is used for almost all search related things on the Mac this sounded very promising. Not only would this fix the problem, but it had more explanation on why the problem occurred in the first place

It seems that once in a while the index isn’t updated correctly. Why and when this exactly occurs is somewhat shady. But since it is the index that is the culprit the solution seems very easy: Rebuild the index.

To rebuild the index you can use the following commands:

sudo mdutil -i off /
sudo mdutil -i on /

The first command disables Spotlight indexing. The second one enables it again.

Note however that now the index is reset that even old unread messages don’t show up. The best thing is to read all your mail before resetting the index.