With imap there is another issue, it's not related to SNI because that should be enabled already if all is well.
You shouldn't need that script normally, it can be done automatically. I've struggled a bit with the same issue some time ago.
Just add imap to this line in your directadmin.conf...