Sending emails with MailKit stopped working on some servers [closed]

1 week ago 10
ARTICLE AD BOX

I've got a C# Windows service that sends out an email using MailKit when the service is started (or if there's been an error). This has been working flawlessly for years. At some point on 23/11, it stopped working with this error:

535: 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [LO4P265CA0130.GBRP265.PROD.OUTLOOK.COM 2025-11-25T08:52:57.800Z 08DE2BB235820936]

Environment:

smtp.office365.com port 587 TLS 1.2

The weird thing is that the same code using the same credentials is working on other machines. I thought it might be anything outside if the domain that was failing but that's also not the case but again it's failing on some machines but not all.

I've created another email account and that one works as you would expect, even on the machines where it's failing with the original account.

This is the code that I've extracted into a simple .exe so I can test it on any server ... it's very basic but as I say, the same credentials work on some servers but not others.

var email = new MimeMessage(); email.From.Add(new MailboxAddress("Connect 2", "[email protected]")); email.To.Add(new MailboxAddress("Mark J", "[email protected]")); email.Subject = "Email send test"; email.Body = new TextPart("html") { Text = "" }; try { using (var client = new SmtpClient()) { // Enforce TLS 1.2+ client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12; client.Connect("smtp.office365.com", 587, MailKit.Security.SecureSocketOptions.StartTls); client.Authenticate("[email protected]", "password"); client.Send(email); client.Disconnect(true); } MessageBox.Show("Email sent"); } catch (Exception ex) { MessageBox.Show(ex.Message); }
Read Entire Article