azure app service office 365 exception The SMTP server requires a secure connection or the client was not authenticated

Murugan Andezuthu Dharmaratnam 116 Reputation points
2024-03-18T13:13:26.3666667+00:00

Exception while sending email smtp.office365.com

It works perfectly fine when I run the application on my desktop but I am getting the error when I run the application hosted in azure app service. 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. [MN2PR01CA0012.prod.exchangelabs.com 2024-03-18T11:50:52.999Z 08DC46A303522B72]

"EmailSettings": {

"Host": "smtp.office365.com",

"Port": 587,

"EnableSsl": true,

"Username": "****",

"Password": "****",

"FromAddress": "**"

},

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,408 questions
{count} vote

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 20,856 Reputation points
    2024-04-01T17:07:23.3866667+00:00

    @Murugan Andezuthu Dharmaratnam Thanks for reply!

    SMTP authentication does not work well in an environment were MFA is enabled , this could be happening because of that.

    You may refer to the article How to set up a multifunction device or application to send email using Microsoft 365 or Office 365 | Microsoft Docs to view the requirements and limitations of smtp.

    Kindly try the following:

    1. In the Azure portal, on the left navigation bar, click Microsoft Entra ID
    2. On the Overview page, in feature highlights section, click Conditional Access.
    3. Go to  Microsoft Azure , sign in with a global admin account
    4. On the Conditional Access page, check the policies and modify them.

    Let us know

    0 comments No comments