不能AUTH以MAILMESSAGE通过放大器和SMTP的Gmail; smtpClient [英] Can't auth to Gmail smtp via MailMessage & smtpClient
问题描述
我无法弄清楚的生命我这是为什么不工作
I cannot figure out for the life of my why this isn't working
SmtpClient smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
UseDefaultCredentials = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential("myemail@gmail.com", "myGmailPasswordHere"),
EnableSsl = true,
Timeout = 10000
};
smtp.Send(mail);
我得到:
SMTP服务器要求安全连接或客户端未通过身份验证。服务器响应为:5.5.1需要验证
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
我刚才指定EnableSsl为true,这样不应该在安全连接方面的问题。
I just specified EnableSsl to true so that shouldn't be the issue in terms of secure connection.
我是从本地主机上运行此。是的,我的用户名和密码,我进入权威性地(我的Gmail帐户凭据)是100%正确的。
I'm running this from localhost. And yes, my username and password I'm entering to auth (my gmail account credentials) is 100% right.
推荐答案
我知道这是一个老话题,但...谷歌已经对他们的安全设置,改变了一些东西。
I know this is an old topic, BUT... Google has changed something on their security settings.
与所有的答案挣扎,直到我检查我的电子邮件与谷歌指出,我们最近阻止您谷歌帐户登录尝试邮件。
Was struggling with all the answers until I checked my email with a mail from Google stating that "we've recently blocked a sign-in attempt on your Google account".
这使我这个页面:
谷歌帐户安全
在安全性较低的应用程序访问部分中,您可以启用来自其他设备/应用程序访问您的帐户...喜欢你的C#应用程序。
Under the "Access for less secure apps" section, you can enable access to your account from other devices/applications... like your C# application.
请注意,有一个专用部分不再。
Note, there is no longer an "application specific" section.
希望这可以帮助别人......我只是失去了我的生活30分钟...
Hope this helps someone... I just lost 30 minutes of my life...
这篇关于不能AUTH以MAILMESSAGE通过放大器和SMTP的Gmail; smtpClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!