535 5.7.3 Authentication unsuccessful

Golubev Maxim 0 Reputation points
2025-02-06T23:37:11.6266667+00:00

Hello I try to use smtp for outlook with microsoft oauth2 in my pet project. I do all thing according https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth#get-an-access-token

  1. register an application in azure and add web redirect uri to "http://localhost"
  2. get authorization code and accept request for my outlook account using URI: "https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?client_id={client_id}&response_type=code&redirect_uri=http://localhost&scope=SMTP.Send offline_access"
  3. get the access token and take from response "refresh_token" which is offline.
  4. get the new request for access token by offline
  5. use javamail to send mail with sasl auth 5. trying to send mail from my outlook mailbox and getting 535 5.7.3 Authentication unsuccessful I debug sasl and check that javamail encoded correctly for sasl. Mayby someone have the same issue.
Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
247 questions
Outlook
Outlook
A family of Microsoft email and calendar products.
4,504 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
5,516 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,759 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sakshi Devkante 925 Reputation points Microsoft Vendor
    2025-02-07T14:18:10.5766667+00:00

    Hello @Golubev Maxim

    Thank you for reaching out to Microsoft Q&A.

    535: 5.7.3 Authentication unsuccessfulFor this error, on the Exchange online side, in addition to enabling authenticated SMTP submission, please check the following points:

    1.Disable Multi-Factor Authentication (MFA) on the licensed mailbox that's being used:

    • In the Microsoft 365 admin center, in the left navigation menu, choose Users > Active users.
    • On the Active user's page, choose Multi-Factor Authentication.
    • On the multi-factor authentication page, select the user and disable the Multi-Factor Authentication status.

    2.Disable Azure security defaults

    3.Check if you have set to exclude users in Conditional Access policies that block legacy authentication

    Based on what you've described thus far it could be app side or even outlook given the next leg of the flow is to connect to outlook after acquiring the access token. This is the article we usually refer to in these scenarios Authenticate an IMAP, POP or SMTP connection using OAuth | Microsoft Docs.

    Based on my search, since you received the errors 535 5.7.3 Authentication unsuccessful. There are a few things you need to check, see under Error: Authentication unsuccessful.

    User's image

    I hope this clarifies things. Please contact us if you have any additional questions.

    Best regards,

    Sakshi Devkante


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.