出于某种原因,既不是接受的答案,也没有其他工作为我“通过Gmail在。net发送电子邮件”。为什么它们不会起作用?

更新:我已经在另一个问题中尝试了所有的答案(接受的和其他的),但没有一个有效。

我只是想知道它是否适用于其他人,否则谷歌可能已经改变了一些东西(以前发生过)。

当我尝试使用SmtpDeliveryMethod的代码段时。网络,我很快收到一个SmtpException发送(消息)。信息是

SMTP服务器需要安全连接,否则客户端未经过身份验证。

服务器的回复是:

5.5.1认证要求在“<——说真的,它到此结束。

更新:

这是我很久以前问过的一个问题,公认的答案是我在不同的项目中使用过很多很多次的代码。

我采用了这篇文章和其他EmailSender项目中的一些想法,在Codeplex上创建了一个EmailSender项目。它是为可测试性而设计的,支持我最喜欢的SMTP服务,如GoDaddy和Gmail。


当前回答

解决这个问题的简单步骤:

1)登录你的Gmail

2)导航到此页面https://www.google.com/settings/security/lesssecureapps并设置“打开”

其他回答

谷歌不再允许“不太安全的应用程序”,所以这对普通gmail用户来说是不可能的。

https://support.google.com/accounts/answer/6010255?hl=en#zippy=%2Cif-less-secure-app-access-is-on-for-your-account

从谷歌:

为了保证您的账户安全,从2022年5月30日起,谷歌号 long支持使用第三方应用程序或设备来询问您 仅使用您的用户名和登录您的谷歌帐户 密码。 重要提示:此截止日期不适用于谷歌工作区或谷歌工作区 云身份客户。这些客户的执行日期 将于晚些时候在工作空间博客上公布。 欲了解更多信息,请继续阅读。

打开访问不太安全的应用程序,它将为所有不需要的工作 修改密码。

链接到Gmail设置

如果以上方法都失败了,下面的方法几乎可以肯定是你问题的答案:

我得到了完全相同的错误,原来谷歌的新密码强度测量算法已经改变,认为我目前的密码太弱,并没有告诉我一件事(甚至没有消息或警告)…我是怎么发现的?好吧,我选择更改密码,看看它是否有帮助(尝试了所有其他方法都无济于事),当我更改密码时,它起作用了!

Then, for an experiment, I tried changing my password back to my previous password to see what would happen, and Gmail didn't actually allow me to do this, citing the reason "sorry we cannot allow you to save this change as your chosen password is too weak" and wouldn't let me go back to my old password. I figured from this that it was erroring out because either a) you need to change your password once every x amount of months or b). As I said before, their password strength algorithms changed and therefore the weak password I had was not accepted, even though they did not say anything about this when trying to login ANYWHERE! This (number 2) is the most likely scenario, as my weak password was about 4 months old, and it let me use it in Gmail.

他们对此只字不提是很糟糕的,但这也说得通。因为大多数被劫持的电子邮件都是使用gmail之外的软件登录的,我猜如果你想在gmail环境之外使用gmail,你需要一个更强的密码。

我解决了这个问题。显然,该消息用于多种错误类型。 我的问题是我已经达到了发送500封邮件的最大值。

登录到帐户并手动尝试发送邮件。如果已达到限制,它将通知您

smtp.Host = "smtp.gmail.com"; //host name
smtp.Port = 587; //port number
smtp.EnableSsl = true; //whether your smtp server requires SSL
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;