我仍然得到发送邮件失败。例外。该内部异常是无法连接到远程服务器和该内部异常是A连接尝试失败,因为连接的方没有正确一段时间后响应或已建立的连接失败,因为连接主机未能响应。我敢肯定,这个原因是不是防火墙设置。有谁知道我能做些什么呢?谢谢你。
VAR邮件= MAILMESSAGE新(username@gmail,destination@gmail.cz) { =主题测试主题,体=检测机构}; 试 { VAR的客户=新SmtpClient(smtp.google,465) { EnableSsl = TRUE, =证书新的NetworkCredential(username@gmail,密码)}; client.Send(邮件); } 赶上(异常前) { Console.WriteLine(ex.Message); }解决方案
下面是需要谷歌设置
-
接收邮件(POP3)服务器 - 需要SSL:pop.gmail
使用SSL:是的。
端口:995
发送邮件(SMTP)服务器 - 需要TLS3或SSL:smtp.gmail (使用验证)
使用验证:是
端口为TLS / STARTTLS:587
SSL的端口:465
帐户名:完整的电子邮件地址(包括@ gmail或 @ your_domain)
电子邮件地址:您的电子邮件地址(username@gmail或的用户名@ your_domain)
密码:您的Gmail密码
I'm still getting "Failure sending mail." exception. The inner exception is "Unable to connect to the remote server" and the inner exception of that is "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond". I'm pretty sure the cause of this is not the firewall setting. Does anyone know what I can do about it? Thanks.
var mail = new MailMessage("username@gmail", "destination@gmail.cz") { Subject = "Testing subject", Body = "Testing body" }; try { var client = new SmtpClient("smtp.google", 465) { EnableSsl = true, Credentials = new NetworkCredential("username@gmail", "password") }; client.Send(mail); } catch (Exception ex) { Console.WriteLine(ex.Message); }解决方案
Here is the Google settings needed:
Incoming Mail (POP3) Server - requires SSL: pop.gmail
Use SSL: Yes
Port: 995
Outgoing Mail (SMTP) Server - requires TLS3 or SSL: smtp.gmail (use authentication)
Use Authentication: Yes
Port for TLS/STARTTLS: 587
Port for SSL: 465
Account Name: your full email address (including @gmail or @your_domain)
Email Address: your email address (username@gmail or username@your_domain)
Password: your Gmail password
更多推荐
未能通过谷歌SMTP发送邮件
发布评论