question

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ asked AliSufyan-1625 answered

The SMTP server requires a secure connection or the client was not authenticated.

The server response was: 5.7.57 Client not authenticated to send mail. Error: 535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [BL1PR13CA0211.namprd13.prod.outlook.com]
It's working fine on local development. but not working on the Azure web app service.

azure-webappsazure-webapps-authentication
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for posting in our Q&A. For this issue, it is not related to windows 365. Windows 365 is a cloud-based service that automatically creates a new type of Windows virtual machine (Cloud PCs) for your end users..

It seems more related to Azure. To get more accurate help, I will add Azure-webapps tag. Thanks.

0 Votes 0 ·

Hi.

Where did the comment's Windows 365 tag come from? Are you trying to use Office 365 for your SMTP server?

The thread below may be close to your question. please make sure.
If that doesn't work, please extract the code for sending SMTP. More detailed information may help.

https://docs.microsoft.com/en-us/answers/questions/512954/535-57139-authentication-unsuccessful.html

0 Votes 0 ·

Thanks for asking question and reaching here! Could you please confirm by looking into your web.config file what is the runtime version of app it is pointing.

Also confirm your application is using the latest TLS (1.2) in Azure. Check this document link where it is mentioned as below:

"For SMTP Inbound mail flow, after deprecation of TLS 1.0 and 1.1, we will accept only TLS 1.2 connection"

Let us know to help you better on this.


0 Votes 0 ·

1 Answer

AliSufyan-1625 avatar image
0 Votes"
AliSufyan-1625 answered

Hi,

Add below line above your code and it should work

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls12;

Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.