This started happening recently (not sure if it was since the last Mavericks update but I think so). I have two IMAP accounts and one SMTP account.
Mail.app seems to get stuck in offline mode if there is any network hiccup, and it refuses to go back online. The only way I can get mail to be sent or received is to quit Mail.app and open it again, and it works great until the next network hiccup.
Other network operations work fine (Safari, Chrome, ssh, etc.) -- it's just Mail.app that exhibits this behaviour.
Has anyone seen this before, or does anyone have any comments on additional things to check to help troubleshoot the issue?