Sometimes, errors can occur in Mail where the program will periodically hang, crash, or freeze, and will require a force-quit. Several things could cause this, including faulty preferences, corrupt mailboxes that need rebuilding, and errors in individual messages that result in odd behavior whenever the message is displayed. In addition to these possibilities, some shared resources that Mail uses could also contribute to crashes and hangs.
One of the first things to try when a program crashes or does not work properly is to remove its preferences. In this case, Mail's preferences are called "com.apple.Mail.plist" and are located in the /username/Library/Preferences/ folder alongside the preferences for most other programs in the system that you have used.
With Mail, the preferences file not only contains custom application settings such as window size, organization, and toolbar customizations, but it also contains e-mail account information. As a result, when the file is removed you will need to re-enter your account setup information so it may be beneficial to, if possible, write down the account settings from Mail before removing the preferences.
Another common source of crashes is plug-ins for Mail. There are a variety of these that include junk mail filters, connectivity for unsupported ISP mail services, and window formatting options. If you have any of these installed, try uninstalling them or updating them with the latest version to see if that helps the situation. Many of these will be installed to the folder /username/Library/Mail/Bundles/, so you may want to check in that location first for any plug-ins.
Mail's mailboxes are relatively simple in their organization, and are essentially folders containing message files, an attachments folder, and an info property list that keeps settings for items like the sort order, whether to show messages in threaded view, and other view options.
To rebuild corrupted mailboxes, launch Mail, select the desired mailbox, and choose "Rebuild" from the Mailbox menu. This may take a while, as Mail runs through each message and checks and catalogues it.
If a rebuild is not possible because Mail crashes or hangs when the mailbox is selected, it is likely that either the mailbox's permissions have been changed so the user account has no read or write access to it, or the property list for the mailbox has been corrupted and is not giving Mail the proper information for view settings and other mailbox organization details.
The mailbox permissions should be set so the owner (the current user account) has read and write access, and everyone else has "no access." To see this, go to the /username/Library/Mail/ folder and get information on the Mail folder itself, as well as the individual e-mail account folders (they should be called something like "IMAPfirstname.lastname@example.org" or "POPemail@example.com") and check the permissions of these items.
Since all files and folders in the "Mail" folder should have the same permissions, you can set them all to be the same from the parent "Mail" folder. Get info on this folder, set the permissions so the username "(me)" is at the top of the list, and remove all other entries except for "everyone." Then select the account username and choose "Make 'username (me)' the owner" from the gear menu, followed by giving the owner "Read & Write" privileges and giving everyone "No Access."
With these settings in place, choose "Apply to enclosed items..." from the gear menu to propagate the permissions to all your mailboxes and e-mail messages (this may take a little while if you have many messages).
If Mail still crashes or hangs when mailboxes are selected, the Mailbox property list could be corrupted. This file is present for each mailbox, so locate it by going to the following folder (the names of the account folder and the mailbox will be different, though MAILBOX is likely going to be "INBOX"):
Locate the file called "info.plist" in this folder and remove it, and then do the same for all mailboxes that are giving you problems. After this is done, launch Mail again and try accessing the mailbox.
Address Book database
Mail is integrally tied to the system's Address Book database, which allows for easy access to contact information from within Mail, as well as for Mail to quickly identify the sender of incoming messages. If there is corruption in the database, when Mail tries to access it the program may hang or crash.
If the Address Book application crashes or hangs as well as Mail, then this is a good indicator that there's corruption in the Address Book database. One option for fixing this is to remove the Address Book storage files, which are located in the /username/Library/Application Support/AddressBook/ folder. They are files that end in ".abcddb" and can be removed from this folder. The Address Book information should be kept in memory, and when you relaunch the Address Book, your contacts should still be there and these files should be recreated.
If you can open Address Book without problems, you may still have problems with the database that could be affecting Mail, so try rebuilding it by archiving your contacts and then clearing and reimporting them. To do this, select "All Contacts" and choose "Address Book Archive" from the File menu (in the "Export" submenu). Save the file in a safe location and then delete all the contacts from the Address Book (make sure you turn off MobileMe syncing before doing this).
Once the Address Book is empty, choose "Import" from the File menu and select the previously backed up Address Book archive to restore.
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.