Are you experincing this error code while trying to configure your custom application to integrate using Microsoft 365:
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.
This error means you used right settings but not suitable to the custom application and 365.
If you are not familiar what are the smtp settings you can used for 3rd part and custom application to be able used 365 as email relay, Here's the reference:
_
https://learn.microsoft.com/en-us/exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-microsoft-365-or-office-365_
Of course, As the developer, email consultant or System admin. you gonna try and try different settings.
To be able to solve these solutions, we need to use app password for the custom application to bypass MFA Authentication (If your custom application can't do MFA/2-factor authentication)
*Here's the procedure to be able produce *
- Enforce the MFA in admin center.
- Open the office of the user > Initial logo > view account > security Info > Add sign-in method > app password > follow the instruction of MS until the app password shows
Kindly take note you need to copy and store carefully the password. basically, this is will be your password for your custom application.
We can now proceed for the SMTP settings in custom application:
_
_**
`Host = "domain.mail.protection.outlook.com",
Port = 25, //Recommended port is 587
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
TargetName = "STARTTLS/smtp.office365.com",
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
using (var client = new SmtpClient("Domain.mail.protection.outlook.com"))
{
client.UseDefaultCredentials = false;
client.Port = 587;
client.Credentials = new NetworkCredential("customapplication@domain.com", "app password we generated above");
client.EnableSsl = true;
`**_
_
Then you can now test.
Top comments (0)