A community member has associated this post with a similar question:
Oauth2 for SMTP.Send granting AccessToken but returns 535: 5.7.3 Authentication unsuccessful when used

Only moderators can edit this content.

535: 5.7.3 Authentication unsuccessful: when using Oauth2 method and SMTP.Send scope

Alex Zonis 70 Reputation points
2023-02-15T19:05:31.6366667+00:00

I am updating the application to support Oauth2 for obtaining (via IMAP) and sending (via SMTP) emails.

Two weeks ago, both IMAP and SMTP were working. But since February 3rd, the application is not able to send emails; it gives me this error:

535 5.7.3 Authentication unsuccessful [SA0PR11CA0169.namprd11.prod.outlook.com 2023-02-15T18:35:20.708Z 08DB0E6A440E41F8]

It worked before. IMAP still works and can receive new emails.

Configurations to get the access token:

'clientId' => [client_id],
'clientSecret' => [client_secret],
'urlAuthorize' => "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
'urlAccessToken' => "https://login.microsoftonline.com/common/oauth2/v2.0/token",	
'scopes' => "openid profile email offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send"

Applications' permissions:

Screen Shot 2023-02-15 at 12.59.23 PM

I use https://swiftmailer.symfony.com/ library to send emails using SMTP. Conversation with the Microsoft server before trying to authenticate using Oauth2 method

 ++ Starting Swift_SmtpTransport
    << 220 SA0PR11CA0169.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 15 Feb 2023 18:35:12 +0000
    
    >> EHLO localhost
    
    << 250-SA0PR11CA0169.outlook.office365.com Hello [2603:8080:2501:df2:487d:8382:4f8b:47c5]
    250-SIZE 157286400
    250-PIPELINING
    250-DSN
    250-ENHANCEDSTATUSCODES
    250-STARTTLS
    250-8BITMIME
    250-BINARYMIME
    250-CHUNKING
    250 SMTPUTF8
    
    >> STARTTLS
    
    << 220 2.0.0 SMTP server ready
    
    >> EHLO localhost
    
    << 250-SA0PR11CA0169.outlook.office365.com Hello [2603:8080:2501:df2:487d:8382:4f8b:47c5]
    250-SIZE 157286400
    250-PIPELINING
    250-DSN
    250-ENHANCEDSTATUSCODES
    250-AUTH LOGIN XOAUTH2
    250-8BITMIME
    250-BINARYMIME
    250-CHUNKING
    250 SMTPUTF8
    
    >> AUTH XOAUTH2 

Other notes:
I have seen similar questions posted by other users. Still, the reply from the Microsoft representative wasn't solving the issue for common tenants and didn't help me to resolve the issue that I have. Links to similar questions:

  1. https://learn.microsoft.com/en-us/answers/questions/1168272/oauth2-for-smtp-send-granting-accesstoken-but-retu
  2. https://learn.microsoft.com/en-us/answers/questions/1168242/smtp-send-oauth-permission-not-working-for-consume
Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
5,125 questions
Microsoft Exchange Online
Outlook
Outlook
A family of Microsoft email and calendar products.
4,011 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,271 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,578 questions
0 comments No comments
{count} votes