使用我的域名从C#winforms发送gmail

编程入门 行业动态 更新时间:2024-10-21 07:44:44
本文介绍了使用我的域名从C#winforms发送gmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好, 我有自己的服务器,我也用它来发送和接收邮件。在第二次遭到黑客攻击后,我放弃并注册了使用我自己的域名处理我的电子邮件的Gmail。 我还启用了两步验证,两次黑客攻击让你保持谨慎。 我想从我的c#windows表单应用程序发送电子邮件,所以我设置了应用程序专用密码。仍然谷歌抱怨安全连接或客户端未经验证(需要5.5.1身份验证)。 在进行搜索时,您会发现很多建议可以为不太安全的应用程序提供保护,这不是我想要做的。 感谢您的想法。 我的尝试:

Hello, I have my own server, and I also used it for sending and receiving mail. After being hacked for the second time I gave up and signed up for gmail handling my email, using my own domain. I also have two-step verification enabled, being hacked twice makes you cautious. I want to send emails from my c# windows forms applications, so I've set up the app specific passwords. Still Google complains about secure connection or client not verified (5.5.1 Authentication required). When doing a search you find a lot of advice to turn of protection for less secure apps, that's not what I want to do. Thanks for your thoughts. What I have tried:

var fromAddress = new MailAddress("myemail@mydomain.toplevel", "From Name"); var toAddress = new MailAddress("myemail@mydomain.toplevel", "To Name"); const string fromPassword = "abcdefghijklmnop"; //app specific password const string subject = "test"; const string body = "This is a test!!"; var smtp = new SmtpClient { Host = "smtp.gmail", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword), Timeout = 20000 }; using (var message = new MailMessage(fromAddress , toAddress) { Subject = subject, Body = body }) { smtp.Send(message); }

推荐答案

我强烈建议您阅读:c# - Gmail错误:SMTP服务器需要安全连接或者客户端未经过身份验证。服务器响应为:5.5.1需要身份验证 - 堆栈溢出 [ ^ ] I'd strongly recommend to read this: c# - Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required - Stack Overflow[^]

您是否遵循了各种配置步骤? SMTP中继:路由传出的非Gmail通过Google发送的消息 - G Suite管理员帮助 [ ^ ] 我可以立即看到的一件事是你没有使用文档中详述的smtp服务器,所以我要做的确定你已经彻底完成了文档,显然你订阅的服务允许中继(从你自己的域发送)。 Have you followed the various configuration steps? SMTP relay: Route outgoing non-Gmail messages through Google - G Suite Admin Help[^] One thing I can see right off the bat is that you're not using the smtp server detailed in the documentation so I'd make sure you've gone through the documentation thoroughly first, and obviously that you are subscribed to a service that allows relaying (sending "from" your own domain).

更多推荐

使用我的域名从C#winforms发送gmail

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

发布评论

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

>www.elefans.com

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