At home I have an Xserve running Snow Leopard Server with IMAP service enabled. This runs all my personal email. Even Gmail and iCloud accounts have their incoming mail forwarded to that server, because I prefer to house my own data. I have dynamic DNS with an MX record. The Xserve also runs DNS and resolves "imap.myip.net" to the internal IP address of the Xserve, and, when I am and work, "imap.myip.net," through the dynamic DNS service, resolves to the outside IP address I have through my ISP. My router forwards external requests on Port 993 to the Xserve internally.
Until recently, I could move my MacBook Pro between home and work and access my email without problems in either place. It appears that since the 10.8.2 update, I can no longer access my email from home, where I am on the same subnet as my IMAP server. When at home, Mail accesses external email servers (Gmail and my work account) without problems. For the accounts on my home IMAP server, the Mail Connection Doctor states that the IMAP server could not be contacted.
However, I can clearly ping it from my MacBook Pro, which means that it is reachable and that my internal DNS is working.
I just fired up my work VPN, and, sure enough, messages that Mail hadn't been able to collect are trondling into my Inbox. In other words, when making Mail access my mail server through the Internet there is no problem.
Even before the Mountain Lion update I found that I had to relaunch Mail when I returned home from work, or Mail couldn't connect to the mail server. It seemed like Mail cached the resolved IP address it had gotten at work, which is the external IP address of my home network, and failed to re-resolved the address of the IMAP server once I woke up the computer, after getting back home. Quitting Mail and relaunching it did resolve that, but it was annoying.
I have never worked with Little Snitch, but it might provide some answers as to what Mail is attempting to do, when it is failing to access the server. Do any of you agree or recognize this issue and have a solution?