We have a problem with emails failing on UAT. It works on my Dev box and in production.
First it was a no certificate error but that was due to after a refresh from production the SMTP settings username and password was not re-entered.
However now I get the error 'A non-recoverable error occurred during a database lookup'.
I am currently just testing the email with the 'Send test email' option on the Email parameters > Test email tab. I get the same error on my new function, so can just as well use the standard option to try and find the issue.
I changed my Dev box to access the UAT database for debugging and have stepped through the code.
It happens on this call: SendMessage method on the "smtpProxy" class.
I cannot see what it does in the SendMessage because it looks like it is a call to a function inside a Microsoft DLL.
While stepping through the code I could see the following:
1) The SysMailerFactory, method ensureSecurityProtocol, shows that the ForceLegacyMailerSecurityBehaviorFlightName returns a NO, so flight name 'ForceLegacyMailerSecurityBehavior' is not enabled.
I can't even find this flightname in the feature management list. Not on Production either. I know flight numbers don't copy over with a refresh from production. but there is no way for me to see if it is turned on in Production if it isn't even in the feature management list of features.
I can see that ServicePointManager, SecurityProtocol is equal to SecurityProtocolType::Tls12
Then with the following piece of code it indicates that SysMailerSmtpMailKitFeatureV2 is enabled because it runs smtpProxy instead of smtpClient..
***
if (SysMailerSmtpMailKitFeatureV2::isEnabled())
{
.....
}
***
Again, there is no way for me to find this flight name in production feature management to see what it is set to. I assume it will be the same because I found a comment in one of the classes that smtpClient is obsolete and that MailKit must be used instead. This is standard code, so I assume Microsoft won't have run the obsolete code.
I also found this link: Common Errors When Sending Email With Mailkit - .NET Core Tutorials (dotnetcoretutorials.com)
The port number is 587 on the SMTP settings and I have changed the Specify if SSL is required from YES to NO. It made no difference if it is set to Yes or No.
So what is needed to fix the error: 'A non-recoverable error occurred during a database lookup'
The Test email is working fine in production. So something is missing in UAT. Because we do not have custom here, I can just assume something is not copied over from production to UAT on a DB refresh.
Any help to get this working is much appreciated.