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

Exception while sending email

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. [ 2024-03-18T11:50:52.999Z 08DC46A303522B72]

"EmailSettings": {

"Host": "",

"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.
6,775 questions
{count} vote

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 18,191 Reputation points

    @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