Mail Search not working El Capitan

With the new mail in El Capitan, when I search for mails from a sender, it does not bring up most of the emails from that sender. This renders the search function in mail unusable.

iMac, Mac OS X (10.0.x)

Posted on Oct 1, 2015 10:41 AM

Reply
116 replies

Jan 23, 2017 2:03 PM in response to Maestro1827

Hello


Our home directory is on an OS X server and not on the local drive


I got the following output!


Last login: Mon Jan 23 20:15:14 on console

Macintosh:~ user$ sudo defaults write /Library/Preferences/com.apple.security.appsandbox UnrestrictSpotlightContainerScope -bool true


WARNING: Improper use of the sudo command could lead to data loss

or the deletion of important system files. Please double-check your

typing when using sudo. Type "man sudo" for more information.


To proceed, enter your password, or type Ctrl-C to abort.


Password:

user is not in the sudoers file. This incident will be reported.

Macintosh:~ user$


How can I solve this?


regards

Gérard

Feb 8, 2017 3:29 AM in response to Maestro1827

another example of how a once fine company is now crappy like microsoft. i've used macs exclusively since 1996. you newbys are thrilled because you were so abused by autistic gates & microsoft for so long. you don't realize how BEAUTIFULLY apple products worked before they adopted intel & abandoned motorola & then the brilliant jobs died several years later. THEIR STUFF JUST DOES NOT WORK ANYMORE. it limps along now. a real tragedy. my finder DOES NOT WORK PROPERLY. reindexing DOES NOT WORK...

Feb 11, 2017 8:59 AM in response to matt buswell

1. Thank you! 🙂 Amazingly, against all odds, this incredible Terminal trick worked for us! It had been WEEKS for us where Apple Mail stopped returning any search results at all (even though the Mac's Spotlight search results were still properly returning results from Apple Mail). This Terminal trick fixed the problem within Apple Mail!


2. However, in order for this Terminal trick to properly work for us, we had to go through several steps BEFORE running the Terminal command. Just running the Terminal command on its own didn't work for us. These are the steps that we had to take to get this to work:


a) We started by quitting out of Apple Mail.


b) Then, in the Finder, we went to ~/Library/Mail/v3/MailData, and trashed all 4 or 5 files starting with "Envelope Index". Note that the "v3" folder might have a different number, depending on which version of Mac OS X you're running. v2=Yosemite, v3=El Capitan, v4=Sierra.


c) The Terminal trick still didn't work for us at this point. So then, we launched Cocktail (Mac utility from maintain.se), and used it to do 2 things:

- Rebuild Mail's Envelope Index (on the "Systems > Databases" screen)

- Cleared all caches (on the "Files > Caches" screen). We also went into Options, and selected all checkboxes.


d) Cocktail will automatically prompt you to restart your computer after clearing the caches, which is what we did next.


e) After the restart, Mail still wasn't searching properly. So it was at this point that we yet again quit out of Apple Mail, and then ran the Terminal command:

sudo defaults write /Library/Preferences/com.apple.security.appsandbox UnrestrictSpotlightContainerScope -bool true


f) Finally, Mail started searching properly again! 🙂

Feb 12, 2017 12:39 AM in response to Scott Rose

Hello


Option e) doesn't work for us because all of our users are networkuser :-(


Last login: Sun Feb 12 09:32:41 on console

Macintosh HD:~ testuser$ sudo defaults write /Library/Preferences/com.apple.security.appsandbox UnrestrictSpotlightContainerScope -bool true


WARNING: Improper use of the sudo command could lead to data loss

or the deletion of important system files. Please double-check your

typing when using sudo. Type "man sudo" for more information.


To proceed, enter your password, or type Ctrl-C to abort.


Password:

testuser is not in the sudoers file. This incident will be reported.

Macintosh HD:~ testuser$


Any suggestion, how to fix it for networkuser?


Regards

Gerard

Apr 4, 2017 9:08 PM in response to Maestro1827

I had this same issue, tried the suggestions here, no luck. After searching a bit online i found someone who had an invisible file at the root of their drive. This didn't show up when doing an LS in terminal either.

running 'mdutil -s <volume>' in terminal gave me the output "Indexing and searching disabled." I navigated to the root of my drive and ran the command "sudo rm .metadata_never_index" to remove the invisible file if it's there. After that I was able to enable indexing with 'sudo mdutil -i on <volume>', indexing status was then enabled and mail searching is working again.


I hope this helps someone

Apr 25, 2017 1:30 PM in response to Maestro1827

I had this problem too, what a frustration!

I tried all what was suggested in these pages and elsewhere: nothing resurrected the searching in Mail.

Last night I decided to leave the computer indexing all night long, started Amphetamine app, so the computer didn't go to sleep but left the screen saver on and lowered the display light to the minimum.

This morning everything works perfectly. In the past days I noticed spotlight sometime was showing the blue bar and sometime not, making you assuming that it was done when it wasn't .

May 21, 2017 9:13 AM in response to matt buswell

Matt - thanks so much for posting this. I too was nervous about it (not being at all familiar with using commands like this in the terminal), but after reading through all the threads again, and looking to see what the sudo command was for, I clenched my teeth and went for it. I have SUCCESS! Thank you.


For anyone else reading this, if it helps, we just recently upgraded to a reconditioned iMac (OS X 10.11.6 El Capitan) from our trusty old iMac late 2006. I performed a 'clean' install, copying over media files and documents etc, and not restoring or creating from a backup. After doing all of this and using the newer machine for a while, I was really frustrated with the mail app because search didn't work at all. I went through a few of the other steps I found in various posts and helpful websites (including manually rebuilding the mailboxes and deleting envelope files from the library - something else that made me a little uneasy); nothing else worked. But this instantly solved the problem. Very helpful. Thanks again.

Oct 31, 2017 6:36 AM in response to Maestro1827

I recently moved my home folder to an external MicroSD card in my laptop (to create space), and search stopped working for me. After trying everything Spotlight related, I realized that my MicroSD was formatted FAT32, and that OS X file privacy restrictions were disabled on that format. As such Spotlight would NOT index anything on that drive.


I backed everything up, reformatted as OS X Extended, restored, and presto...worked! Of course, invalidated ALL of my account permissions and preferences, but I'm up and searching faster than ever.

Oct 6, 2015 11:36 AM in response to Maestro1827

You need to re-index Mail.


Quit Mail

Open System Preferences/iCloud and uncheck Mail

Close/Quit System Preferences

<Here I would Restart your Mac, but you probably don't have to>

Open Mail (it should be devoid of all Mail unless you have it checking other Mail accounts like Gmail)

Open System Preferences/iCloud and check Mail

Close/Quit System Preferences

From Message Viewer, look at the bottom of your Mailboxes List

(you may have to toggle it by clicking on the little icon below the Check Mail Menu Bar Item)

You will see your Mail being downloaded from iCloud. This could take some time!

...and when that completes, your Mail will be indexed, and the Search function will work once again.

Oct 14, 2015 4:29 AM in response to Maestro1827

I am having the same problem - the search function will not work on my mail after upgrading to El Capitan. I tried re-indexing my mail via Spotlight with no luck. I don't back-up my email to iCloud (I have Time Machine backing up to an Airport Time Capsule), so the above method will not work. I even tried manually re-indexing by using the following method:

  • 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

    Unfortunately, my MailData file contains only one file (Accounts.plist), so this does not work, either. I use the search function a lot, so any suggestions in fixing this would be greatly appreciated.


    Thank you

    This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

    Mail Search not working El Capitan

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