How to sort new folders alphabetically in OS X Mail?

I am running OS X Yosemite and Mail v8.2. Every time I add a new folder, Mail puts them to the bottom folder structure. This is very confusing and I have to go through all folders all the time to find my stuff. I would like the mailboxes to stay in alphabetical order. How can I do that? This was just working fine in previous version.

Any good solution? Disable and Enable the IMAP account is not option.


Steve Price's answer pointed me in the right direction. I'm running El Capitan, and found the .mboxCache.plist files under /Users/my login/Library/Mail/V3. The file is a text file, and can be edited with a text editor (after closing the mail program).

For folders appearing in the wrong place, the problematic entries are as follows:

                    <key>MailboxDisplayIndex</key>
                    <integer>0</integer>

The value "0" puts the folder at the beginning, higher values go later in the list.

If you simply remove the two above lines for any folder appearing in the wrong place, and restart Mail, those folders will go back to being sorted alphabetically.

Sometimes the following two lines also appear in combination with the above:

                    <key>MailboxIsManuallySorted</key>
                    <true/>

In those cases, I changed "true" to "false".

Now my folders are back where I want them, yay!


I am running Mac OS Sierra on a late 2009 iMac 27". My Mac iCloud account mailboxes were NOT in alphabetical order and I have too many to manually sort. Disabling and enabling IMAP Mail for my Mac iCloud account did not work for me. This did the trick perfectly.

  1. Stop Mac application
  2. Run these commands at a command line prompt in bash or ksh. (Substitute your user name where you see "steve" below. Substitute whatever you like for "Nov-12-2016". That is just arbitrary stuff to rename the files and to be able to find them if needed later):
cd /Users/steve/library/Mail/V4

for file in $(find . -name .mboxCache.plist)
do
    print mv $file ${file}.Nov-12-2016
    mv $file ${file}.Nov-12-2016
done

I really wish Apple would just fix this bug once and for all. But until they do, when I see my Mailboxes are out of order I will run my script.

I cannot figure out how to get this simple ksh code to format correctly here, even though I read the help and tried the code and block quote buttons. So the code as shown has too many empty lines and spaces. Sorry for that.

Steve Price


Practical Solution

Keep one Mac around with a copy of Snow Leopard. When you want to add mail folders, do it inside Mail 4.6. The folder will go into alphabetic order automatically. It will show up in the right place on all your other computers as well. I've just tested this on a large Apple Mail 4.6 archive. The 2005 Test folder is brand new and showed up in the right order.

I've added 2005 Test and it showed up right away in the right place

I'll try and test this functionality in the powerful and utilitarian MailMate as you may be able to add your folders there (staying in Yosemite) but doing your actual writing and reading inside Apple Mail. MailMate looks and acts a lot like a cross between Apple Mail 4.6 and Eudora (my two favorite email programs) but is still a bit different in how it manages HTML emails and even reply quotes which keeps me away from using it voluntarily on a full time basis: we are creatures of habit. On the upside, MailMate does offer Markdown.

Frankly I'd be a lot keener to upgrade more of my five Macs past Snow Leopard if I could keep the amazing and robust Apple Mail (along with Letterbox for my very large monitors: the new two line viewing system is not nearly as good as clean columns).

Optimistic Suggestion

There may be a hidden preference default write which would enable automated alphabetic sorting. I can't find one but perhaps an Apple engineer could leak one to us.

As examples here's some other useful default write commands for Apple Mail:

defaults write com.apple.mail DisableReplyAnimations -bool true
defaults write com.apple.mail DisableSendAnimations -bool true

Change default font size and/or reset it:

defaults write com.apple.mail MinimumHTMLFontSize 12
defaults read com.apple.mail MinimumHTMLFontSize
defaults delete com.apple.mail MinimumHTMLFontSize

Turn on and off inline image viewing:

defaults write com.apple.mail DisableInlineAttachmentViewing -bool true
defaults write com.apple.mail DisableInlineAttachmentViewing -bool false

Turn off Mail sent sound and turn it back on:

defaults write com.apple.mail MailSentSoundPath dummy
defaults delete com.apple.mail MailSentSoundPath

Copy and paste only the email address without name (this is a good one which I run by default on all my Macs:

defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool true