Skip to main content

Stopping OS X's from storing locally IMAP messages

TL;DR: Mail.app wants you to download your messages even if you change manually the account .plist. Forget about it.

I wanted to stop Mail.app in OS X 10.10 Yosemite from caching locally my IMAP messages. Once upon a time there was right there in Mail.app an option to do just that, but for the last couple of OS versions the only option shown there is whether to download the attachments or not.




I saw that other people were looking for the same thing, and the best solution proposed seemed to be to limit at the server the number of mails shown to the client. But that kinda sucks, because of the not very convincing reason that I want to have easy, comfortable access to all my years of mails, always. First world problems, baby.

My IMAP provider is Gmail, so another option would be to limit at the server + using the Gmail app for anything needing greater access on iOS (I am guessing it doesn’t get limited in the same way than IMAP). Or using the webmail, of course. iOS’s Mail at least can do searches on the server, but I the desktop Mail can not. (ugh!)

Anyway, trying to keep my existing configurations as unchanged as possible, I hoped for another possibility: that some “defaults” command or hidden preference would still enable the old behaviour.

The most interesting finds are:

  • Mail.app writes an Accounts.plist file containing the key CachePolicy, and the attachment downloading checkbox toggles its value between CacheAllMessages and CacheAllBodies
  • That key and those values appear in /System/Library/PrivateFrameworks/Mail.framework/Versions/Current/Mail. Other value that appears right there is CacheNoMessages. Bingo!
  • I tried looking for a defaults command which would change that, and couldn’t (it’s scary to see all the cruft that one can find just by scratching in there a bit). 
  • So I tried the direct option: changed the key inside of Accounts.plist, and started Mail.app.

… and it didn’t work. The very first thing Mail.app does is to helpfully notify you that to use it you have to download all the messages in your account, and you can either do it at the moment or quit. My messages were still stored locally at that point, so I guess Mail.app just checked the CachePolicy key, saw that it had an outdated value, and bailed out into a migrate-to-the-new-policy mode.



So, no need to look for a defaults command, since Mail.app won’t work in that mode anyway.

I have been using Thunderbird for years at work. Maybe I should just switch to it at home too…

Comments