简体   繁体   English

发送smtp gmail电子邮件``失败发送邮件''

[英]Send smtp gmail email ''Failure sending mail''

I am trying to send email in c# using gmail smtp server but it giving me an error `Failure sending mail``. 我正在尝试使用gmail smtp服务器在c#中发送电子邮件,但它给我一个错误消息``发送邮件失败''。

Everything is fine username and password. 一切都很好的用户名和密码。 What wrong with this code that can cause this error? 该代码有什么错误会导致此错误?

 var client = new SmtpClient("smtp.gmail.com", 587)
            {
                Credentials = new NetworkCredential("myusername@gmail.com", "mypassword"),
                EnableSsl = true
            };
            client.Send("myusername@gmail.com", "myusername@gmail.com", "test", "testbody");
            Console.WriteLine("Sent");
            Console.ReadLine();

我认为这对您会更有帮助https://support.google.com/a/answer/176600?hl=zh_CN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM