连接尝试失败是因为连接的一方在一段时间后未正确响应,或者连接建立失败是因为连接的主机未能响应... [英] 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...

查看:191
本文介绍了连接尝试失败是因为连接的一方在一段时间后未正确响应,或者连接建立失败是因为连接的主机未能响应...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



发送邮件时出现以下错误,

连接尝试失败,因为一段时间后连接方未正确响应,或者建立的连接失败,因为连接的主机未能响应74.125.127.108:465

我的代码有什么问题?

这是我的代码,

Hi,

while sending mail i got the following error,

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 74.125.127.108:465

What is the issue in my code?

Here is my code,

SmtpClient client = new SmtpClient();
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.EnableSsl = true;
                client.Host = "smtp.gmail.com";
                client.Port = 587;
                // setup Smtp authentication
                System.Net.NetworkCredential credentials =
                   new System.Net.NetworkCredential("Mailid", "Pwd");
                client.UseDefaultCredentials = false;
                client.Credentials = credentials;
                MailMessage msg = new MailMessage();
                msg.From = new MailAddress("Frommailid");
                msg.To.Add(new MailAddress("Tomailid"));
                msg.To.Add(new MailAddress(lmail+","+admin_mail));
                msg.CC.Add("CCmailid");
                msg.Subject = "UserName_and_Pwd";
                msg.Subject = "Registration";
                msg.IsBodyHtml = true;
                msg.Body = "UserName ='" + un + "' and Pwd='" + pd + "'";
                //msg.Body = string.Format("<html><head></head><body>Test HTML Email</body>");
                try
                {
                    client.Send(msg);
                    return 1;
                    //lblerror.Text = "Your message has been successfully sent.";
                }
                
                catch (Exception s)
                {
                    throw (s);
                }



有人可以帮我解决这个问题吗?



Can anyone help me to solve this?

推荐答案

这种类型的错误,当我们尝试在代理服务器中发送电子邮件时得到的...
尝试在主服务器中运行此代码.
This type error we get when we try to send email in proxy server...
Try running this code in main server..


尝试此代码

try this code

MailMessage msgMail = new MailMessage();
                                MailMessage myMessage = new MailMessage();
                                myMessage.From = new MailAddress("from@xyz.com","sample");
                                myMessage.To.Add(txtemail.Text);
                               
                                myMessage.Subject = "welcome";
                                myMessage.IsBodyHtml = true;

                               
                                SmtpClient mySmtpClient = new SmtpClient();
                                System.Net.NetworkCredential myCredential = new System.Net.NetworkCredential("from@xyz.com", "password");
                                mySmtpClient.Host = "mail.gmail.com";
                                mySmtpClient.UseDefaultCredentials = false;
                                mySmtpClient.Credentials = myCredential;
                                mySmtpClient.ServicePoint.MaxIdleTime = 1;

                                mySmtpClient.Send(myMessage);
                                myMessage.Dispose();




使用带有C#的ASP.NET发送邮件 [ ^ ]
Hi,

Send mail using ASP.NET with C#[^]


这篇关于连接尝试失败是因为连接的一方在一段时间后未正确响应,或者连接建立失败是因为连接的主机未能响应...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆