Troubleshooting case: Tackling stubborn Mail preferences

When application settings do not stick in OS X, it's easy to just remove the preferences file; however, sometimes it's useful to investigate the problem a little before doing this.

Many times when program settings don't stick properly a common troubleshooting step is to "delete the preferences file," which will remove any custom settings and have the program re-create the preferences file from defaults. This step is so commonly recommended it's almost cliche, but sometimes it's fun to take a look at exactly how preference corruption manifests itself.

Recently MacFixIt reader Fredrick contacted me with a problem that had all the indications of being from preference file corruption:

With my Mac Mini and Snow Leopard, I now find that I can't keep my "Columns" settings for Sent Mail. Instead of "To" (the obvious choice), one column keeps reverting to "From" (that's me, and I know who sent the mail!). This has never happened before under any system, with any Mac.

In this instance we have a program (Mail) that is not accepting settings changes, suggesting that preference file corruption might be to blame. Before simply recommending to remove the preference file, it was useful to see if perhaps Mail was merely not able to write to the preferences file, in which case an easy solution would be to troubleshoot the permissions settings for the file and thereby save custom program settings. To check this, I had Fredrick monitor the values in the preferences file as he changed the settings in the Mail program.

There are a couple of ways to monitor settings in a preferences file:

Mail preferences in textwrangler
In a text editor you can see the preference file's attributes for the Sent Items viewer. Screenshot by Topher Kessler
  1. Use a text editor
    By opening Mail's preference file in a text editor, you can see what the various settings values are. In this case, you can open the file called "com.apple.Mail.plist" (located in the /username/Library/Preferences/ directory) in TextEdit or in a more robust editor like TextWrangler.

    If you use TextEdit, then when the preferences file is changed you'll need to re-open the document to see the changes; however, TextWrangler is beneficial because it will detect when changes have happened to the preferences file and update it live so you don't need to reload the file.

  2. Use the "defaults" terminal command
    Apple's Terminal command for manipulating property lists is called "defaults" and can be used to both make modifications to a preferences file and also read out values from it. If you first open the Mail preferences file in a text editor and scroll through it (beware: it's quite long), you'll find among all the settings that there's one called "SentMessagesViewerAttributes." This attribute (also called a "key") is at the root level of the preferences file (directly within the encompassing "plist" tags), which makes it easy to target with the "defaults" command in the Terminal in the following manner:

    defaults read com.apple.Mail SentMessagesViewerAttributes
    The defaults command showing settings changes
    By repeating the "defaults" command in the Terminal you can see the settings change when you make alterations to them in Mail (click for larger view). Screenshot by Topher Kessler

    This command will tell the "defaults" program to read out the value of the "SentMessagesViewerAttributes" key (which, as its name suggests, stores the "Sent Messages" view options--the area where Fredrick was having issues with Mail), so we can use it to read any changes to this section of the Mail preferences file. The command references the property list by its "domain" (the "com.apple.Mail" section), but you can also provide the full path to the Mail preferences file in the following manner (note the ".plist" extension to the file name is left out):

    defaults read ~/Library/Preferences/com.apple.Mail SentMessagesViewerAttributes

    Regardless of how you target the preferences file with this command, when you run it the command should output the keys valued to the Terminal, so if you make a change to Mail's settings and then repeat this command, the changes should be reflected in the Terminal's output.

When Fredrick used the defaults command in this manner to see what was happening to Mail's preferences settings as he changed them in the program, it was clear the settings were being saved to the preferences file, so Mail was able to access the file properly. However, despite these changes, when the program was relaunched the views in the "Sent Items" section would revert, indicating that the Mail preferences file was corrupt elsewhere.

Unfortunately this finding meant that the easiest solution would be the cliche one of clearing out the preferences file and having Mail rebuild it from default settings--and on doing this Fredrick's problem went away.

In many cases checking a preferences file for permissions access like we did here isn't needed, but in the case of Mail the program stores quite a bit of information (including account information) to the preferences, so setting it up again can be a bit of a burden, especially if you have multiple accounts set up in Mail. Therefore, performing these steps to help determine whether the preferences file is truly corrupt was beneficial, and luckily in the case of Mail the mailbox organization and downloaded messages are preserved, so all that's needed is for the user to re-enter account information.



Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.

Tags:
Computers
About the author

    Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.

     

    Join the discussion

    Conversation powered by Livefyre

    Don't Miss
    Hot Products
    Trending on CNET

    HOT ON CNET

    Last minute back to school shopping?

    Whether you're looking for headphones to study with or music-streaming gear, CNET rounds up a shopping guide just for you.