RT5, stunnel and office365

I have been having issues getting RT5 sending email through office365, the connecttion has to be secured by certificates. I could not get postfix to work, but on another legacy system I used stunnel to connect securely so that it could send directly to office365. I have set up stunnel on the RT server with the following config:
# Global Options
client =yes
output = /var/log/stunnel
debug = 7
#taskbar = yes

# Service Level Options
pid = /var/run/stunnel.pid
cert = /etc/letsencrypt/live/<domain.com>/fullchain.pem
key = /etc/letsencrypt/live/<domain.com>/privkey.pem

[SMTP Outgoing]
protocol = smtp
accept =
connect = smtp.office365.com:587
sslVersion = all
options = NO_SSLv2
and set a connector on office365 - this connects successfully! I can telenet to the office365 mail smtp server

I then put the following mail settings in RT_SiteConfig.pm
Set($MailCommand, ‘’);
Set($SendmailPath, ‘’);
Set($SMTPServer, ‘’);
Set($SMTPPort, 587);
Set($SMTPDebug, 1);

when replying to a ticket I get the following error in RT
Could not send mail with command -oi -t

Does anyone know how to fix this error. Has anyone successfully used stunnel with RT if so , how did you get it working?