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
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:
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: