First step is to make sure you can send and receive emails with your mail server; sendmail, postfix, whatever. Once the mail server is working, then attack the IMAP server. The hardest part for me was the authentication so that users could send mail from their remote devices; laptop, tablet, phone, etc. It all appeared correct but still was refusing relaying. Finally after wasting a day with it I chucked all the configuration and dump the keys and started over. It worked perfectly and I had no idea what was wrong with the first; my guess is it was the keys; I generated self-signed keys using OpenSSL.