> Well, that kinda complicates a "STARTTLS tunnel" Perhaps you might be interested in these commands. I'm not sure about their portability but they work tolerably well in scripts on Mac OS X 10.6.
$ openssl s_client -connect yourhost:imap -starttls imap $ openssl s_client -connect yourhost:pop3 -starttls pop3 $ openssl s_client -connect yourhost:imaps $ openssl s_client -connect yourhost:pop3s $ openssl s_client -connect yourhost:smtp -starttls smtp