当我尝试从C#发送电子邮件的SMTP例外
MailMessage mail = new MailMessage("[email protected]", "[email protected]");
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "pwd");
client.UseDefaultCredentials = false;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
型“System.Net.Mail.SmtpException”未处理的异常发生在System.dll中 附加发送电子邮件我有这样的错误信息:SMTP服务器需要安全连接或客户端未通过身份验证。 服务器响应是:5.5.1需要身份验证。
检查,如果您可以登录到从应用程序上运行的计算机的Gmail帐户。有时谷歌可以阻止远程计算机访问。还检查是否启用了2因素身份验证。 – user1666620
检查您的Gmail帐户的安全设置,并启用不太安全的应用程序 – Sybren
也许[这些](http://stackoverflow.com/questions/9801224/smtpclient-with-gmail)答案将帮助您 – voytek