未能通过谷歌SMTP发送邮件

编程入门 行业动态 更新时间:2024-10-24 11:25:31
本文介绍了未能通过谷歌SMTP发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我仍然得到发送邮件失败。例外。该内部异常是无法连接到远程服务器和该内部异常是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发送邮件

本文发布于:2023-10-13 00:13:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1486271.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送邮件   SMTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!