Hi @CL , let me know if https://learn.microsoft.com/en-us/answers/questions/512954/535-57139-authentication-unsuccessful.html is helpful in resolving your issue.
Unable to send email from Azure App service using Mailkit, but printer/scanner can send fine
CL
1
Reputation point
I get an error:
MailKit.Security.AuthenticationException: 535: 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully.
We're using port 587 with TLS 1.2. The IP Address of the App Service is whitelisted.
using (var client = new SmtpClient())
{
client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;
await client.ConnectAsync(_emailSettings.MailServer, _emailSettings.MailPort, SecureSocketOptions.StartTls);
System.Security.SecureString psw = new System.Security.SecureString();
foreach (char item in _emailSettings.Password.ToCharArray())
{
psw.AppendChar(item);
}
await client.AuthenticateAsync(new NetworkCredential(_emailSettings.Sender, psw));
await client.SendAsync(message);
await client.DisconnectAsync(true);
}
Any help would be greatly appreciated. thanks
2 answers
Sort by: Most helpful
-
Ryan Hill 29,666 Reputation points Microsoft Employee
2022-05-24T17:17:28.15+00:00 -
Nick Beckley 1 Reputation point
2022-06-22T15:02:49.267+00:00 I've had similar today and it turns out that basic authentication has been turned off with Microsoft 365 email. You now have to use OAUTH2. Of course it might be something very different but I know of others this has happened to.