Without knowing significantly additional information about your setup, I would suggest attempting to use dovecot for imaps/pop3s.
If you already have ssl certificates (for qmail- you should if you're using tls/ssl/smtp auth) you can simply point dovecot to them and tell it to enable the protocols.
In the dovecot.conf (usually in /etc or /etc/dovecot) add imaps and pop3s to the protocols line in the config, and then add lines for the ssl certificates:
Code:
ssl_cert_file = /path/to/your/cert/filename.crt
ssl_key_file = /path/to/your/cert/filename.key
Then start dovecot (service dovecot start or /etc/init.d/dovecot start).
Connect and see if it works.
Hope it helps!