Share via

Authenticate an SMTP connection using OAuth failed.Sever replied: Sever replied: '535 5.7.3 Authentication unsuccessful'

Anonymous
2025-04-24T09:41:48+00:00

During September 2025, we will remove support for Basic auth with the Client Submission (SMTP AUTH) endpoints: smtp.office365.com smtp-legacy.office365.com  Once Basic auth is permanently disabled, any clients or apps connecting using Basic auth with Client Submission (SMTP AUTH) will receive this response:550 5.7.30 Basic authentication is not supported for Client Submission. What do I need to do if I can use OAuth with Client Submission (SMTP AUTH)? If your client supports OAuth, follow these steps: Authenticate an IMAP, POP or SMTP connection using OAuth https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth Because of the above reasons, I have to use oauth authentication smtp connection. I refer to above link development. I don't know if I understand it correctly.I refer to this step to develop. 1. I register my application with Microsoft Entra. The permission requested by the application is Mail.Send,offline_access,SMTP.Send,User.Read. 2.Get an access token with OAuth2 device authorization grant flow. post https://login.microsoftonline.com/common/oauth2/v2.0/devicecode To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXX to authenticate. Use this account(@outlook.com) to authenticate successfully. post https://login.microsoftonline.com/common/oauth2/v2.0/tokenSuccessfully obtained the token The permission is Mail.Send,SMTP.Send.      "token_type": "Bearer",     "scope": "SMTP.Send Mail.Send",     "expires_in": 3600,     "ext_expires_in": 3600,     "access_token": "EwA4BMl6BAAUBKgm8k1UswUNwklmy2v7U/S+1fEAAb9XPqpV+OBTrTnCSfEoa4y9lzlLbRy/HGMJ... 3. smtp server : smtp.office365.com , port 587, starttls. I use SASL XOAUTH2 format to encode and transmit the access token.  base64("user=" + userName + "^Aauth=Bearer " + accessToken + "^A^A"). The base64 decoded string is user=@outlook.comauth=Bearer EwA4BMl6BAAUBKgm8k1UswUNwklmy2v7...U C: auth xoauth2 S: 334 C: dXNlcj1xaWFuNjY1MEBvdXRsb29rLmNvb... S: 535 5.7.3 Authentication unsuccessful [SI2PR06CA0012.apcprd06.prod.outlook.com 2025-04-24T09:33:05.942Z 08DD81FD8DFF148B] I have obtained a token and have been authenticated to have sufficient permissions.  Why does the SMTP server fail to authenticate? Is there something wrong with my username? Or is there something wrong with the app settings? Or is there a token permission issue?

Microsoft 365 and Office | Install, redeem, activate | Other | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2025-04-24T10:23:18+00:00

    The screenshot of my submission instructions is as follows:

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2025-04-24T10:17:14+00:00

    Why can't my submission message have a carriage return or line break?

    Was this answer helpful?

    0 comments No comments