You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

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

rebuild mailboxes

I have Gmail IMAP set up on Mail.app on macOs. There are roughly 20 email folders in the gmail account that are synced to Mail.app


Often the emails in the middle column do not correspond to the email message that shows up when you select it. A different email is displayed when selecting one from the list.


Rebuilding the mailbox will temporarily fix this problem for a day or so, but it keeps coming back. This happens on nearly all the mailboxes except for default the Inbox, Drafts, Sent, etc. But it happens on all the other mail boxes, and so rebuilding them every few days gets very tiring.


This doesn't occur when I log into my gmail account via the web app.


Does anyone have any suggestions as to what might be going wrong or how to fix it? Thanks

MacBook Air 13″, macOS 10.14

Posted on Oct 20, 2020 9:22 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 21, 2020 10:04 PM

Hey there!


Is Gmail the only account you have in Mail? Just curious if the same happens in the Mail app, with other account’s mailboxes.


Another good test, (Besides safe mode), is to sign into a new admin account, as Gmail and test.


I’d say if it works fine in the new user, but issue persists in safe boot:


I’d either reset user permissions, or:


I’ve had luck in Catalina and Mojave, which are a little different than previous OS’, with these steps:


Make sure you have a backup.

Even if IMAP accounts I may still export each mailbox as an extra backup, (Can never be too careful).


Quit the Mail app.


Open Finder.


While holding “Option”, click on “Go”.


Then select “Library”, (You can let go of “Option” now).


Open “Containers” and select “com.apple.mail”


Select “File” then “New Folder (With Selection)”, this will just make another backup.


Next in the same ~/Library, open Mail > V7 > Mail Data.


Select all the files beginning with “Envelope Index”, and again, move to the trash, or another location as another backup.


Then open the Mail app while holding the Shift key, you’ll be promoted to import your mail as if it was the first time, depending on the amount, may take a while.


Afterwards, you can test, (Note that you may need to hover the cursor to the right of “On My Mac” mailboxes to select “Show” to show them again.


On a side note though, if the same behavior happens in both a new user and safe boot, (Whether or not how it reacts on other devices). Google, in particular has many settings, (Labels, tags, etc), that affect how it shows up in the OS. I have seen one small Gmail setting change from the web completely change mail behavior on Mac OS despite other accounts working just fine.

I also know that now Google now requires you to allow Mac OS to view your mail, sometimes you need to delete and re-add the account to even be prompted for that. (That might be a good step in of itself). And whether or not you have any local rules set up in Mail Preferences, might make a difference, but to me it sounds most likely like an indexing issue, in which the steps above would typically fix.


Hope it works out!


To reset the permissions:

https://support.apple.com/guide/mac-help/change-permissions-for-files-folders-or-disks-mchlp1203/mac


Similar questions

9 replies
Question marked as Top-ranking reply

Oct 21, 2020 10:04 PM in response to andrewks9

Hey there!


Is Gmail the only account you have in Mail? Just curious if the same happens in the Mail app, with other account’s mailboxes.


Another good test, (Besides safe mode), is to sign into a new admin account, as Gmail and test.


I’d say if it works fine in the new user, but issue persists in safe boot:


I’d either reset user permissions, or:


I’ve had luck in Catalina and Mojave, which are a little different than previous OS’, with these steps:


Make sure you have a backup.

Even if IMAP accounts I may still export each mailbox as an extra backup, (Can never be too careful).


Quit the Mail app.


Open Finder.


While holding “Option”, click on “Go”.


Then select “Library”, (You can let go of “Option” now).


Open “Containers” and select “com.apple.mail”


Select “File” then “New Folder (With Selection)”, this will just make another backup.


Next in the same ~/Library, open Mail > V7 > Mail Data.


Select all the files beginning with “Envelope Index”, and again, move to the trash, or another location as another backup.


Then open the Mail app while holding the Shift key, you’ll be promoted to import your mail as if it was the first time, depending on the amount, may take a while.


Afterwards, you can test, (Note that you may need to hover the cursor to the right of “On My Mac” mailboxes to select “Show” to show them again.


On a side note though, if the same behavior happens in both a new user and safe boot, (Whether or not how it reacts on other devices). Google, in particular has many settings, (Labels, tags, etc), that affect how it shows up in the OS. I have seen one small Gmail setting change from the web completely change mail behavior on Mac OS despite other accounts working just fine.

I also know that now Google now requires you to allow Mac OS to view your mail, sometimes you need to delete and re-add the account to even be prompted for that. (That might be a good step in of itself). And whether or not you have any local rules set up in Mail Preferences, might make a difference, but to me it sounds most likely like an indexing issue, in which the steps above would typically fix.


Hope it works out!


To reset the permissions:

https://support.apple.com/guide/mac-help/change-permissions-for-files-folders-or-disks-mchlp1203/mac


Nov 15, 2020 1:14 AM in response to andrewks9

Hey again! Been a while! Glad that worked out, for the time being anyway.


As for that, I’ve seen that quite a bit, the system remembers old servers that you’ve even deleted in the past, so when sending a message you get the error, hit the option to choose a different server, and see all the past servers.


YET When you open Mail Preferences > Accounts > Account Info > Server Settings > Edit SMTP Server List, those ghost/old servers aren’t there!


I’d first quit the Mail app, and re open while holding the Shift key, bypassing the last “Saved State” as it’s called, do they still appear then? If not, then that would be another solution.


Otherwise, resetting the user permissions as I said before may be the fix. If it’s not updating the servers as it should. However that’s a tricky one.


You may need to remove ALL of your Internet Accounts, (After backing up of course), Restart your Mac, then Re-Add one by one checking to see if they re-appear, if not, good.


If so, it could be related to the Keychain, see this post:

https://discussions.apple.com/thread/8124247


Some there recommend deleting the Keychain entries for “smtp” in Keychain Access, just be sure, as always, before doing so, you backup, and/or know your account passwords as they will need to be re entered on your Mac at some point.


I do think it’s a valid step as well, has worked for me actually for the same issue, but not all issues/steps are a one-in-all fix, but worth a shot definitely.


All this can even be related to your previous issue with the indexing, I’d suspect that it would work just fine in a new admin account, indicating an issue with settings/accounts/permissions/user preferences/configurations. (Although that’s not always the case).


Anyhow hope one of the steps help out!


Nov 14, 2020 11:22 PM in response to DiZoE

Hi DiZoe,

So my mailboxes didn't end up being fixed with the previous solution, so I finally got around to trying your solution of deleting the various folders and files in ~Library, and it seems to work so far so fingers crossed that this will stick. Otherwise I'll just delete and re-create the account in Mail and wait for it all to re-download.


One other issue I have that maybe you can help with: My list of SMTP servers seems to be corrupt. The list shows 4 servers, but when I click to edit the server list, there are only 2 there. Also, sometimes when I make changes to one of the servers, or to a newly created server, the changes don't stick after I quit and relaunch Mail. This is all happening since before, and after, deleting the folders from ~Library, so it seems the server list is not being stored in any of those folders. Would you know if there's any file I can delete to reset the server list? Thanks so much

Nov 15, 2020 1:39 AM in response to DiZoE

Thanks for such a thorough reply!

So launching Mail with shift still shows the server list with the "ghost" servers, which are not visible when I click "Edit server list".


In terms of resetting/changing user permissions, I'm not quite sure what you're suggesting. The article you linked shows different ways of changing the user permissions for folder, but which folders do you suggest I change the permissions of? And change them to what settings?


I've gone ahead and deleted a few different keychains that might be related to these smtp servers, also the com.apple... one mentioned in that thread.


So far no luck. Also, while my ghost smtp server works, the new one doesn't. Also sometimes all the info fields for that server reset completely, but its just a visual glitch, because if I re-open the server-list the info is still there.


If you can clarify what you mean about permissions I'll try that, and if that fails I'll delete and re import the accounts

Nov 15, 2020 10:00 PM in response to andrewks9

Hey again!


The official procedure for that has changed since Catalina, and as far as I know (And have tried), this is closest to the newer method of resetting user permissions:


https://www.google.com/amp/s/eclecticlight.co/2020/03/28/apple-has-changed-resetting-permissions-again/amp/


This requires also reinstalling the OS as well, however, I know this problem has been around a while, and Big Sur just came out, so I’d probably recommend upgrading the OS.


If you can’t, you can reset them the previous way, (Which with testing myself also still works):


Open Finder > Go > Home.

Hit Command i on the keyboard to Get Info.

Disclose Sharing and. Permissions on the bottom by clicking the triangle to the left.

Hit the gear icon to the left of the lock and select “Apply to enclosed items”.


Wait for that small progress window to disappear, (There is no time line unfortunately so can take anywhere from one minute to hours, but usually quick).


Once that window disappears, open Terminal from Applications/Utilities/Terminal.

Enter this in the Terminal window:


diskutil resetUserPermissions / `id -u`


Then press Return, and wait for the process to finish, Terminal will let you know when done. Then restart and test it out.


I would first suggest though (Also if you’re Mac can’t support Big Sur or you’re unable to upgrade for any reason), just backing up, removing all the Internet Accounts, restarting, then restart adding one at a time though, testing after each addition. As long as you backup, (Even just exporting each mailbox), have IMAP accounts, You should be fine to do this.

rebuild mailboxes

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