【发布时间】:2016-03-17 14:44:21
【问题描述】:
当我使用以下 gmail 帐户之一时,我有一个 C# .Net 代码通过 gmail 发送电子邮件:
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("test@example.com","Test12345");
smtp.Timeout = 9000;
smtp.Send(MMsg);
有效的电子邮件是我过去使用的电子邮件,但我们需要将此电子邮件更改为新电子邮件。任何新的电子邮件凭据都不起作用。它给了我错误:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Line 120: smtp.Credentials = new NetworkCredential("test@example.com", "Test12345");
Line 121: smtp.Timeout = 9000;
Line 122: smtp.Send(MMsg);
知道我错过了什么吗?如何通过应用程序使其他新电子邮件起作用?
更新: 我必须在谷歌网站https://www.google.com/settings/security/lesssecureapps 上打开“访问不太安全的应用程序”才能使其工作。
【问题讨论】:
-
您的凭据不正确。仅通过查看您的代码,我就可以看到您没有提供正确的电子邮件帐户
-
你检查了这个答案吗? stackoverflow.com/a/298379/4995166 试试这个。我认为它会为你工作
-
错误信息对我来说似乎很不言自明...您的凭据错误。
-
@NguyenHoang 你不会真的期望他提供他的 gmail 登录凭据。显然已经匿名了。