SuiteCRM 8.5 Unable to send email using SMTP.Office365.com server in OUTBOUND EMAIL ACCOUNT

Hi,

I have created the Microsoft External OAuth Provider and External OAuth Connection using the steps given in the reference document.

All the required permissions mentioned in the document are provided to the Azure App and enabled the SMTP settings too.

**SMTP details are as follows: **
SERVER: smtp.office365.com
USE SMTP AUTHENTICATION?: true
Port: 587
MAIL SMTP/SSL: TLS
USERNAME: myemailid
Password: mypassword

Problem:
When I try to use this SMTP as a OUTBOUND EMAIL ACCOUNT. i’m not able to send the emails through it.

Error Log:
3: Connection: opening to smtp.office365.com:587, timeout=300, options=array()
3: Connection: opened
2: SERVER → CLIENT: 220 PN2PR01CA0216.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 25 Jul 2024 07:42:30 +0000 [08DCAC4EFBDD772D]

1: CLIENT → SERVER: EHLO localhost

2: SERVER → CLIENT: 250-PN2PR01CA0216.outlook.office365.com Hello [223.31.8.150]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8

1: CLIENT → SERVER: STARTTLS

2: SERVER → CLIENT: 220 2.0.0 SMTP server ready

1: CLIENT → SERVER: EHLO localhost

2: SERVER → CLIENT: 250-PN2PR01CA0216.outlook.office365.com Hello [223.31.8.150]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH LOGIN XOAUTH2
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8

1: CLIENT → SERVER: AUTH LOGIN

2: SERVER → CLIENT: 334 VXNlcm5hbWU6

1: CLIENT → SERVER: —obfuscated—
2: SERVER → CLIENT: 334 UGFzc3dvcmQ6

1: CLIENT → SERVER: —obfuscated—
2: SERVER → CLIENT: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled. [PN2PR01CA0216.INDPRD01.PROD.OUTLOOK.COM 2024-07-25T07:42:39.477Z 08DCAC4EFBDD772D]

1: SMTP ERROR: Password command failed: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled. [PN2PR01CA0216.INDPRD01.PROD.OUTLOOK.COM 2024-07-25T07:42:39.477Z 08DCAC4EFBDD772D]

3: SMTP Error: Could not authenticate.
1: CLIENT → SERVER: QUIT

2: SERVER → CLIENT: 221 2.0.0 Service closing transmission channel

3: Connection: closed
3: SMTP Error: Could not authenticate.

Can anyone help. What am I missing here.

For outbound you have to create an “app password” for each user and use that as outbound connection. Your Azure login/password will not work. There is also a setting in Azure to allow this or not. If this is not allowed, even creating an app password will connect for outbound.