Mail.app encounters recurring connection error (to Gmail IMAP server) after installing Mountain Lion
This happened to me while in Snow Leopard. It's a different situation, however I fixed it by removing the mail account, and re-adding it fresh. Worked forever after that.

-Z