Is there a way in code to check if an SmtpClient and NetworkCredential is valid as part of a HealthCheck. I don't particularly want to be generating emails every 10 mins, but I'd like to know that the server is responsive and more importantly that the NetworkCredentials haven't been reset without us knowing about it :-)
Current code block is this; but as far as I can tell this isn't making any calls out from the service.
public bool IsHealthy()
{
try
{
var smtp = new SmtpClient(this.options.SmtpHost, this.options.SmtpPort)
{
UseDefaultCredentials = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(
this.options.EmailUserName,
this.options.EmailPassword,
this.options.EmailDomain)
};
// Should really be calling something in here?
smtp.Dispose();
return true;
}
catch
{
return false;
}
}