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.