The following error is probably the most common error you will see while setting up SMTP email in Dynamics 365 Business Central.
“The mail system returned the following error: “A call to MailKit.Net.Smtp.SmtpClient.Authenticate failed with this message: 5.7.3 Authentication unsuccessful”
This is a generic error that simply means that authentication to the Exchange Online server was unsuccessful. You can easily reproduce this error by putting in your username and an incorrect password. Assuming you’re using the correct username and password though, there are many other reasons you may be running into this error. I will walk through all of the areas that you can check to try and resolve this problem if you’re running into it.
MFA is Enabled
There are several different ways to enable and use MFA in your organization. If you are utilizing any of these methods, then it will cause this error to occur. You must either setup and use an App Password or disable MFA for the user running SMTP. Please see this previous blog post for more information.
Azure Security Defaults
If you have Azure Security Defaults enabled, it will block SMTP from working. You can check on this with the following steps:
- Navigate to https://portal.azure.com with a Global Admin for the tenant.
- Go into ‘Azure Active Directory’
- Click on ‘Properties’ on the left hand menu
- Click on ‘Manage Security defaults’ link at the bottom of the page
- The option for ‘Enable Security defaults’ must be set to ‘No’
- If you’d like to get more information about this setting, go HERE
SMTP or Basic Auth is disabled in Exchange Online
It is possible to have SMTP or Basic Authentication disabled in your Exchange online environment. To check on this it will require that you connect through PowerShell.
The following article discusses how to connect to Exchange Online in PowerShell
Once you’re connected, you will want to check on the settings based on the following articles.
Get-AuthenticationPolicy | Format-Table Name -Auto
When you run the command to check and see if they have an Authentication policy setup to disable Basic Authentication, you should get no results. It will look like this:
Get-TransportConfig | Format-List SmtpClientAuthenticationDisabled
When you run the command to check and see if SMTP Authentication is disabled, you should get a result of ‘False’. If you return the value ‘True’, then SMTP is disabled, and you can use the document linked above to find and run the command to change it to false.
If you change either of the above settings through PowerShell, it can take some time to propagate through the servers and you see a change. The above settings resolve 99% of the support cases I see for this error. If you’re still struggling to get this setup you can always open a support case.