SmtpClient, change authentication type of credential
using (var client = new SmtpClient())
{
client.UseDefaultCredentials = false;
client.Host = setting.Host;
client.Port = setting.Port;
client.EnableSsl = setting.EnableSsl;
CredentialCache cache = new CredentialCache();
// authentication type: gssapi, ntlm, WDigest, login
cache.Add(setting.Host, setting.Port, "login", new NetworkCredential(setting.UserName, setting.Password));
client.Credentials = cache;
using (var message = new MailMessage())
{
var body = System.IO.File.ReadAllText("content.email");
message.From = new MailAddress(setting.Sender);
message.ReplyToList.Add(new MailAddress(setting.Email));
message.To.Add(new MailAddress(setting.Receiver));
message.IsBodyHtml = true;
message.Body = body;
message.Subject = setting.Subject;
message.BodyEncoding = Encoding.UTF8;
message.SubjectEncoding = Encoding.UTF8;
try { client.Send(message); }
catch (Exception ex)
{
Log.Write(ex);
}
}
}