Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Leopard's Spotlight doesn't search Mail messages

Leopard's Spotlight isn't searching email messages. I made a clean install of 10.5, and have two POP accounts. The message files are right there under ~/Library/Mail/... . I rebuilt the index for the system volume by adding and then removing the volume from the Privacy zone in Spotlight preferences. I also tried some of the command-line suggestions posted elsewhere for this problem. I recently added my backup volume to the privacy zone, but other than that the zone is empty.

But the problem remains. Outside Mail.app, Spotlight never comes back with search results that are mail messages. Inside Mail.app, searching "entire message" returns 0 results. Does anyone know how to diagnose this problem? Can I see if a particular file is included in the metadata index?

PowerMac G5, Mac OS X (10.5), clean install

Posted on Nov 4, 2007 3:32 PM

Reply
Question marked as Best reply

Posted on Nov 4, 2007 3:36 PM

Mike,

In System Preferences>Spotlight>Privacy do you have any files excluded?

Matt
89 replies

Nov 4, 2007 8:53 PM in response to Matthew Morgan

Matt, my Backup volume is listed in SP>Spotlight>Privacy. The Backup volume is an additional, non-system partition on the internal hard drive. There are no other files or directories listed. I've also done a lot of experimentation (aimed at fixing this problem) while the list was empty.

My mail of course is on / , specifically /Users/(username)/Library/Mail.

-Mike

Nov 5, 2007 5:03 PM in response to JJ81

Thanks JJ, I don't think I saw that particular thread before. I have seen many others. I was disappointed because I hoped to see a solution to your problem in that thread, since your description matches my problem exactly. In that thread, the following fixes are suggested:

- quit and restart Mail (doesn't solve the problem for me or JJ)
- rebuild mailboxes (doesn't solve the problem for me or JJ)
- mdimport ~/Library/Mail (works for some people, but doesn't solve problem for me or JJ)
- mdimport~/Library/Mail (it was funny reading this exchange - "i get 'command not found'...is that what you get?")
- "deleting the various Envelope* files" - sounds interesting, what's the theory here?
- calling Apple (waste of time for JJ and another person who tried it)

I'll try to find out what the Envelope files are for, and report back. (There's a file called "Envelope Index" in ~/Library/Mail).

I should point out to anyone having this problem, that the first thing to check is System Preferences > Spotlight > Privacy (click the Privacy tab), and check to see if Mail or any other files or directories are shown in the list of things for Spotlight to skip over. Remove any such items. This was what Matt was getting at. Also, if you do something funny like changing the name of your home directory or using symlinks, you're asking for trouble.

The second thing to try is to rebuild the Spotlight index on your system volume (the volume that has your mail files) by adding the system volume to the Privacy list, and then removing from the list again. Have patience, it takes many minutes (maybe hours of minutes) for it to rebuild. Click on the spotlight icon in the upper right corner of your screen to see progress on the rebuild.

Needless to say, these two simple things haven't worked for me (or JJ either, apparently).

Nov 5, 2007 7:42 PM in response to JJ81

I said I would try to find more information about the "Envelope Index" file. The file ~/Library/Mail/Envelope Index is the SQLite database that Mail uses for metadata search--all search except "entire message" searching. The file is irrelevant to the problem with full-text search. As you may know, Leopard Mail uses Spotlight to do "entire message" searching.

Nevertheless, for the sake of completeness, I quit Mail and deleted the "Envelope Index" file and restarted Mail. No difference (Mail rebuilt the file and behaves exactly the same as before). For other people who have been using Mail a while and find it slow, this procedure might make things faster. Mail sure gives a scary message when you delete the file, talking about "reimporting" mail.

Nov 15, 2007 3:30 PM in response to Mike Wilkens

Hahaaaa! Solved it - at least for me...

Please read the whole explanation first before just gabbing any presented commands and executing them in the Terminal. The solution requires no Terminal.

I had exactly the same problem described by MikeW and JJ. I tried everything like you before at no avail, too. But I tried one more thing that did work and indexed all my mail. Here is what I did at the command line. Don't type the command right away. It will work, but this is not the root cause of your problem, I present it just to explain:

find ~/Library/Mail -name "*.emlx" -exec mdimport {} \;

This searches for the individual message (*.emlx) files themselves and throws them one by one onto the mdimporter which imports them just fine. Still, a plain mdimport ~/Library/Mail would not work which pointed me in the right direction: Spotlight did not "see" these individual message files. But Why?

I fiddled a bit with file/folder permissions since I also simply upgraded from Tiger and ended up with old Tiger permission based user accounts. No result. I discovered, that in Finder the mailboxes, say ~/Library/Mail/Mailboxes/INBOX.mbox etc. were displayed as package files instead of folders. Strange. So again I tried mdimport -d1 ~/Library/Mail now with a bit of debugging. Aha! Spotlight imports this folder as type 'dyn.ah62d4rv4ge81g45mr3wgn8a', or similar, a dynamic UTI, instead of with 'com.apple.mail.mbox' as what it should have been. Since this unknown dynamic UTI dosn't mean anything sensible to Spotlight, it would simply skip the folder, not scanning it's contents with the well known result that mails cannot be searched by content.

So, what is essentially overwriting these UTIs? Especially because this would not happen in another Leopard-created user account. I felt guilty as I added some custom UTIs in the past, but nothing to do with mail at all. So who carries UTIs for Mail.app? Well... Mail.app! Another Mail.app? YES! I remembered, that I had an older complete pre-Spotlight system backup on my current system, including all applications including Mail.app in version 1.3.something. AFAIK only with Mail 2.0 Apple changed the way Mail saves messages and they apparently also changed the UTI of .mbox to the new format. I simply deleted the old version of Mail.app. Immediately after that the icons of the .mbox changed and I could open these folders in Finder. I tried again mdimport ~/Library/Mail and - boom - Spotlight imported all my mails!

Long story to explain my thoughts, here are 5 steps for you to try:

1. Search your system to find out if you have multiple different copies of Mail.app. You can do that with Spotlight/Finder or enter in the terminal:

sudo find / -type d -name "Mail.app" -ls

(You need to be admin to sudo, type your password when prompted)

2. Locate and check the found versions of Mail.app in Finder via the get info window.

3. Delete all but the actual copy of Mail.app in /Applications from your system (empty trash!).

4. Enter the following line in the terminal to have Spotlight import your messages:

mdimport ~/Library/Mail

Should take much longer now, depending on the number of mails you have.

5. Check the result by searching mail content in Mail/Finder/Spotlight, enjoy!

Note: If you did find and delete old versions of Mail.app, but step 4 did not work, you might have to log out and in or you can even try to restart the machine. In my case the result was instant. If all of that did not work for you - sorry - but probably the above helps you to track your particular problem down.

ecke

Nov 15, 2007 5:30 PM in response to ecke

Great post Ecke! My INBOX.mbox is also showing a dynamic UTI. (You can see the UTI by using debug level 1 with mdimport: /usr/bin/mdimport -d1 ~/Library/Mail/.../INBOX.mbox )

I used to have another Mail.app on my system too, on another hard drive (the original drive that came with the computer and which contained MacOS 10.3). That drive is now disconnected, leaving the new hard drive with a fresh 10.5). So it seems like since I never explicitly deleted Mail.app, MacOS didn't get a chance to "update" the UTI associated with this folder, as it did on your system.

Anyway, I'm currently reading up on UTIs and Launch Services so I can find out how to make Mail.app claim INBOX.mbox properly. I've verified that Mail.app/Info.plist shows an entry for .mbox files.

Thanks again for a very helpful post!

Leopard's Spotlight doesn't search Mail messages

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.