Small performance improvement on imap_open

Use the OP_HALFOPEN flag to reduce server load. We don't need to open a mailbox, so just don't try
I've also make the check clearer for the opened connection (I know, 2 PR in one, it's bad…)