各位先进好,最近想写一个利用Gmail或Yahoo的mail server发信的程式,不过遇到了瓶颈,不知各位先进是否有相关经验,或目前正在使用此功能的先进可以帮忙一下,感激不尽!
以下是我的简单设定内容:
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.Credentials = new System.Net.NetworkCredential("account", "password");
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Send(mms);
整个程式mail server的部份我有改用公司的mail server设定,是确定可以发送出去的没问题,只是改用gmail或yahoo的mail server就会遇到问题,目前已遇到两三种error,找了google大师都没有找到解答,故上来求救一下!
Error log 1:(使用gmail)
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
下列方法已做,将gmail的[允许安全性较低的应用程式] 设定处于启用状态=>啓用
solution 1 for case 2: go to security settings at the followig link https://www.google.com/settings/security/lesssecureapps and enable less secure apps . So that you will be able to login from all apps.
Error log 2:(使用yahoo)
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Authentication required
已经不知道还有什么方法可以嚐试解决了,先谢谢各位帮忙了~感激!