Sometimes problems like this are caused by an overloaded Server, or by problems with the Server that takes it offline.
Do not be in a big hurry to blame your Mac. It could be your Mail provider is the one having the problem. This is likely to be so if you are having the same access difficulties from multiple devices.
Java (the article tagged in your initial post) should have NOTHING to do with Mail.