On Nextcloud Version 19.0.1 The solution is to add this to your config.php
file.
"mail_smtpstreamoptions" => array(
'ssl' => array(
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false
)
),
This solved the problem for me.