AlfonsoPC
PHPMail/Sendmail is used as a fallback (last resort) when SMTP fails. So this shouldn't be necessary once you get SMTP working.
Maybe try disabling Authenticated SMTP and re-enabling it for the email (in O365 Admin Center)?
Are you using localhost or a domain name with HTTPS configured? If HTTPS, are you using a certificate from a trusted CA or a certificate from a local CA (self-signed)?
Cheers.