Please check out Client was not authenticated to send anonymous mail through Office 365 for the latest information on this topic. |
A client of ours that uses Office 365 Enterprise is generating an SMTP authentication error:
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM xxxxx.yyyyy.prod.outlook.com]
MailMessagemessage = newMailMessage();
message.From = newMailAddress(*** Email address is removed for privacy ***);
message.To.Add(newMailAddress("*** Email address is removed for privacy ***"));
message.Subject = "Test message 07:22... Test message 07:22... Test message 07:22... ";
message.Body = "Test message 07:22... Test message 07:22... Test message 07:22... Test message 07:22... Test message 07:22... Test message 07:22... Test message 07:22... Test message 07:22... Test message 07:22... ";
SmtpClientsmtp = newSmtpClient();
smtp.Host = "smtp.office365.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = newNetworkCredential(*** Email address is removed for privacy ***", "Password");
smtp.Timeout = 600000;
smtp.Send(message);
Obviously email and password changed. We have verified the password is good using OWA. We have this exact code working for several clients that are using non-Enterprise Office365 and Exchange 2016.
We will look at the logs today when onsite, but are looking for help. We have viewed on several posts that people have gotten this error and by simply changing the password and changing it back it clears. This is not the case for us.