Mail.app - Downloading Attachments or Not

Have you been using Apple’s Mail.app for a while, and the size of the stored mail is simply increasing with no end in sight? You can tell Mail.app to not store attachments locally, delete the mail, and re-download just the text content. Assuming you can use the Terminal a bit, here’s how:

Screenshot showing Mail.app settings for disabling attachment downloading.If you set up Mail.app in OS X to download attachments for an IMAP account, and then later decide you do not want to store a copy of each attachment locally, you can change the account settings so that only the headers are downloaded. You can make the setting in Mail.app Preferences, but, it takes a while to synchronize. Sometimes a good looong while.

Assuming OS X 10.5.5 and that all your mail is already up on the server, first, set “Keep copies of messages for offline viewing” to “All Messages, but omit attachments” in Preferences, Accounts, Advanced.

Next, shut down Mail.app, to get it to release the folder we’ll now work on. Then bring up a Terminal, cd into the appropriate IMAP folder and confirm and delete the contents using the rm command (again, this assumes you have the mail up on the server already):

Delete Inbox in Preparation for Re-Download
1
2
3
4
5
6
[user@system]$ cd ~/Library/Mail/
[user@system]$ ls -la
[user@system]$ cd IMAP-myaccount@mailhost.mydomain.com
[user@system]$ ls -la
[user@system]$ rm -rf INBOX.imapmbox
[user@system]$ rm -rf etc

Before you delete, check what is in there using the ls command, and the size of the folders using the du command:

Use du to get folder sizes
1
2
3
4
5
6
7
8
rcogley@RickMBP ~/Library/Mail/V2 % du -hsc *
2.2G IMAP-rcogley_work@mail.webfaction.com
 15G IMAP-rick.cogley@imap.gmail.com
4.0K Mac-rick.cogley
162M MailData
235M Mailboxes
460K RSS
 17G total

Next time you restart Mail.app, it will rebuild the folders it needs, under your IMAP folder.

Warning: Don’t bone-headedly delete your email without a backup!

Enjoy!

Update 20130124: Still works in OS X Mountain Lion but the mail folders are in a V2 subdirectory, which you need to CD into.