Since a few days, my application fails sending SMTP email. The app is in fact a scheduled task (which is running on my local machine, written in C#, using SmtpClient) and occasionally needs to send one (or a few) emails. The code is similar to this:
var smtpClient = new SmtpClient();
var mailMessage = new MailMessage(
from, // account in my domain
to,
subject, body)
{
IsBodyHtml = true
};
smtpClient.Send(mailMessage);
Here's the relevant configuration section from my app.config file:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network enableSsl="true"
port="587"
userName="validuser@example.com"
password="********"
host="smtp.office365.com">
</network>
</smtp>
</mailSettings>
</system.net>
Note that
- This has worked for over a month
- Nothing in the code has changed
- I'm the only administrator of the Office 365 subscription, and haven't touched anything (I haven't even logged into the admin page) in the last month or so
- I can still log in into Office 365 using the credentials in the config file
- Suddenly, since a few days, I now get an SMTP error: "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated"
What could be causing this issue? Is there any logging or other diagnostics I could turn on to find out more information?