Hi,
I have an azure Entra ID Subscription where I have created user and the email with my domain, For example (ABC@abcemi.com) and I tried to send mail programmatically.
Here are the steps that I have followed to Send Mail via .NET core code: -
First, I have set MFA authentication to Enforced, so I can create app password then I have created an app password.
second, I have grant admin consent to SMTP, Mail permission via azure portal to my account.
Third, I have granted the SMTP Authenticated app to use mailbox through Microsoft365 admin center.
Fourth, below is the code that I am using: -
in the App settings I am using the this
"EmailDetails": {
"smtpServer": "smtp.office365.com",
"EnableSsl": "true",
"smtpPort": "587",
"smtpUser": "My Azure Entra Tenant Mail",
"smtpPass": "App password generated earlier",
"DefaultCred": "false"
}
but whenever I try to send mail it gives an error that is :
"System.Net.Mail.SmtpException: '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, user is locked by your organization's security defaults policy. Contact your administrator. [SJ0PR03CA0089.namprd03.prod.outlook.com"
Any help would be appreciated, Thanks.