Tip: Leopard Mail.app won’t quit with IMAP

Apple Logo
I recently setup several IMAP accounts in Leopard’s Mail.app and noticed that when I tried to quit Mail, it would “hang”. This seems to be a common problem and I found a fix which may work for you too.

The problem is puzzling and annoying. You try to File->Quit in Leopard’s Mail application and it just sits there. If you wait long enough, it might quit on its own, but typically, you must do a Force Quit.

I tracked the issue down to something to do with IMAP accounts. When I had Mail configured for only POP access, it would quit on-demand any time. However, as soon as I added just one IMAP account, Mail again refused to exit cleanly. Clearly, there’s something wrong with Apple’s IMAP implementation in Leopard and they aren’t exactly jumping to fix it.

Anyway, I found a “fix” that worked for me. I now have six IMAP accounts setup in Mail and when I try to quit, it exits within a second or two, cleanly. This may or may not work for you, and make sure you have a backup just in case — although this shouldn’t cause any problems, you know the standard “do this at your own risk” disclaimer applies.

1) Exit Mail and make sure it has fully quit (use Force Quit if required).
2) Run these commands from a Terminal:


sqlite3 ~/Library/Mail/Envelope\ Index vacuum;
sqlite3 ~/Library/Mail/Envelope\ Index vacuum index;
sqlite3 ~/Library/Mail/Envelope\ Index vacuum subjects;

You can just cut and paste the lines exactly as-is.

3) Open Mail, wait for any of the initial inbox checking to complete, and test quitting.

I suspect that if you have lots of mail stored on the server that it will still take a few seconds to shut everything down, but in my case with very little existing mail, Mail now closes in about 1-2 seconds.

Hopefully Apple will release an update at some point in the near future, but there are reports of this happening all the way from Leopard 10.5.1 through the 10.5.4 that I’m running.

Please post below if this helps you so everyone can gain from the experience.

11 thoughts on “Tip: Leopard Mail.app won’t quit with IMAP”

  1. Marc: there is nothing to undo – those commands are simply built-in database commands that optimize and clean the tables. You should check for other problems with your mail provider, network, or other settings as that’s your most likely cause of problems. For a bit more about the sqlite3 vacuum command check this out.

  2. Thanks for this tip– it worked exactly as described. I have to say I’m underwhelmed switching from Tiger’s Mail.app to Leopard’s. I’ve had nothing but problems since about a week after I initially set it up. Hanging on Quit seems to be resolved now, thanks to these database commands.

    Thank you again!

  3. Do you do all your own writing? Or do you outsource some of it? I’m looking for some similar content for my blog! These are great posts!

  4. You have no idea how many headaches you have saved me. Your tip combined with watching the activity indicator has made using mail convenient again.

  5. I used your tip, even though I have Mail.app under Snow Leopard, and it worked like a charm. Thanks for the great information!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.