发送邮件失败:C#:Gmail:无法从传输连接读取数据:现有连接被远程主机强行关闭
Failure sending mail :C#:Gmail: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host
我在使用 C# 控制台应用程序发送电子邮件时遇到错误。它之前工作得很好,但它开始给我错误,下面是我的代码
smtp.Host = "smtp.gmail.com";
smtp.Port = Convert.ToInt32(587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.ServicePoint.MaxIdleTime = 60;
smtp.Timeout = 20000;
smtp.Credentials = new NetworkCredential(UserName, Password);
ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtp.Send(msg);
错误
我还在 google 设置中将 'Allow Less Secure Apps' 更新为开启
有人知道吗
我已经自行解决了这个问题。我必须授予 AD 服务帐户适当的权限,才能从地址
发送任何 SMTP
我在使用 C# 控制台应用程序发送电子邮件时遇到错误。它之前工作得很好,但它开始给我错误,下面是我的代码
smtp.Host = "smtp.gmail.com";
smtp.Port = Convert.ToInt32(587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.ServicePoint.MaxIdleTime = 60;
smtp.Timeout = 20000;
smtp.Credentials = new NetworkCredential(UserName, Password);
ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtp.Send(msg);
错误
我还在 google 设置中将 'Allow Less Secure Apps' 更新为开启 有人知道吗
我已经自行解决了这个问题。我必须授予 AD 服务帐户适当的权限,才能从地址
发送任何 SMTP