使用 Mailkit:"The SMTP server has unexpectedly disconnected."
Using Mailkit : "The SMTP server has unexpectedly disconnected."
我正在尝试使用 SendGrid 的免费 SMTP 中继从我的 ASP.NET 应用程序发送电子邮件。我可以连接到服务器,但是当我尝试进行身份验证时,出现此错误:"The SMTP server has unexpectedly disconnected."
using (var client = new SmtpClient())
{
client.ServerCertificateValidationCallback =
(sender, certificate, certChainType, errors) => true;
client.AuthenticationMechanisms.Remove("XOAUTH2");
// connection
client.Connect("smtp.host", 465, true);
client.Authenticate("UserName", "Password");//error occurs here
client.Send(email);
client.Disconnect(true);
}
再一次,我可以毫无问题地连接,但是当我尝试进行身份验证时,出现了前面提到的错误...
有什么建议吗?
干杯
我正在尝试使用 SendGrid 的免费 SMTP 中继从我的 ASP.NET 应用程序发送电子邮件。我可以连接到服务器,但是当我尝试进行身份验证时,出现此错误:"The SMTP server has unexpectedly disconnected."
using (var client = new SmtpClient())
{
client.ServerCertificateValidationCallback =
(sender, certificate, certChainType, errors) => true;
client.AuthenticationMechanisms.Remove("XOAUTH2");
// connection
client.Connect("smtp.host", 465, true);
client.Authenticate("UserName", "Password");//error occurs here
client.Send(email);
client.Disconnect(true);
}
再一次,我可以毫无问题地连接,但是当我尝试进行身份验证时,出现了前面提到的错误...
有什么建议吗?
干杯