Cannot get smtp tls to work

I installed phplist and am trying to configured smtp with tls but it refused to work for a week now with no luck. If i comment out the below, it does send out email but when i try to enabled tls, it failed with the bottom error.

define(‘PHPMAILERHOST’, ‘localhost’);
$phpmailer_smtpuser = ‘smtpuser’;
$phpmailer_smtppassword = ‘smtpuserpassword’;
define(‘PHPMAILERPORT’,587);
define(“PHPMAILER_SECURE”,‘tls’);

ubuntu 16.04 LTS with virtualmin

CLIENT -> SERVER: STARTTLS
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS"
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
SMTP Error: Could not connect to SMTP host.
CLIENT -> SERVER: QUIT

any help would be appreciated.
Thanks