Jelly Bean IMAP, Couldn't open connection to server Well, finally got my Nexus 7. Set up all the basics and hit a pretty big roadblock, the email account setup for IMAP simply won't work.

Just to clarify, I'm absolutely certain all the details I've put in are 100% correct, I've double-, triple-, quadruple- and so on-checked them. They are exactly the same as the settings I use on my iPhone, in Mail.app on my Mac and in Thunderbird on my laptop. All three of these devices are on the same network behind the same FreeBSD machine that does packet filtering, they are all on the same subnet and subject to the same packet filtering rules.

The IMAP(S) server is my own running on a Debian VPS and here's the kicker, when I check the logs all the other clients' connections are clearly visible but no connections from the Nexus 7 show up. The Nexus 7 has shown no other signs of network issues but whenever I try to setup an IMAP account I get Couldn't open connection to serverthrown back at me immediately (no delay indicating some kind of timeout, immediate, right away, BAM!).

So, does anyone have suggestions on how I can fix this? I've tried googling but every forum post and blog post I've come across has been so obviously about other things (most of them along the lines of "I'm trying to my email what is server?" which means the answers aren't very helpful).

Edit: I've also tried a complete factory reset but I'm still getting the same error.

Edit2: I am able to telnet from the tablet to the IMAP server and when I do so everything that should get logged in /var/log/mail.log on the server gets logged there but when I attempt to setup an account in the settings and click Next I still don't see anything in the logs. I'm starting to have suspicions that this is either something strangely broken in the the IMAP client libraries or some kind of IPv6-related screwup (since the server is accessible through both IPv4 and IPv6).
Ok, I tried restarting the IMAP server with no luck and then I decided to try a second factory reset, not that I was expecting it to work but apparently something changed because suddenly it worked and I have no idea why. Ah, the magic of user-friendliness.