jab*_*idi 2 c# smtp smtpclient smtp-auth mailkit
我正在尝试使用 SendGrid 的免费 SMTP 中继从我的 ASP.NET 应用程序发送电子邮件。我可以连接到服务器,但当我尝试进行身份验证时,收到此错误:“SMTP 服务器意外断开连接。”
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);
}
Run Code Online (Sandbox Code Playgroud)
再次,我可以毫无问题地连接,但是当我尝试进行身份验证时,我收到前面提到的错误......
有什么建议么?
干杯
| 归档时间: |
|
| 查看次数: |
21693 次 |
| 最近记录: |