The quickest solution for now is to quit Mail, and re-open it. Then all of the connections are reset, and your email is back to normal. This seems to be a bonified bug. Here is a discussion about it:
Sunday, November 4, 2012
Mail Keeps Going Offline
Many users are experiencing problems with Apple Mail since installing Mountain Lion (I noticed it on my Mac since installing the 10.8.2 update.). The problem often appears upon waking, after your Mac has been asleep (of course, when else would it wake up?!) All of your IMAP mail accounts will be offline, with the dreaded circle of evil, as I call it. Although I cannot be sure that it is an IMAP issue, my Comcast account, which is POP, is not having the same issue.
I'll let you know when there is a fix...