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

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

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

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

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

服务器的回复是:

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

更新:

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

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


当前回答

You can also connect via port 465, but due to some limitations of the System.Net.Mail namespace you may have to alter your code. This is because the namespace does not offer the ability to make implicit SSL connections. This is discussed at http://blogs.msdn.com/b/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx, and I have supplied an example of how to use the CDO (Collaborative Data Object) in another discussion (GMail SMTP via C# .Net errors on all ports).

其他回答

You can also connect via port 465, but due to some limitations of the System.Net.Mail namespace you may have to alter your code. This is because the namespace does not offer the ability to make implicit SSL connections. This is discussed at http://blogs.msdn.com/b/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx, and I have supplied an example of how to use the CDO (Collaborative Data Object) in another discussion (GMail SMTP via C# .Net errors on all ports).

我得到了同样的错误,上面的解决方案都没有帮助。

我的问题是,我是从一个远程服务器上运行的代码,而这个服务器从未用于登录gmail帐户。

我在远程服务器上打开浏览器,并从那里登录到gmail。它问了一个安全问题来验证是我,因为这是一个新的位置。在做了安全检查后,我能够通过代码进行身份验证。

我还发现我曾经登录的账号被谷歌出于某种原因停用了。一旦我重置了密码(和以前一样),我就可以正常发送电子邮件了。我也收到了5.5.1的消息。

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

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

为您的帐户打开不太安全的应用程序:https://www.google.com/settings/security/lesssecureapps