连接尝试失败 - 在asp.net mvc中发送Smtp.Send

时间:2015-03-28 07:39:05

标签: c# asp.net asp.net-mvc email

我现在正试图发送消息很长一段时间。但是Stmp.send失败并发出错误。

  

连接尝试失败,因为连接方没有   在一段时间后正确回应,或建立连接   失败,因为已连接的主机无法响应202.71.99.194:25

 System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(
                             new System.Net.Mail.MailAddress("email@yahoo.com", "Web Registration"),
                             new System.Net.Mail.MailAddress(user.Email));
                    m.Subject = "Email confirmation";
                    m.Body = string.Format("Dear {0}<BR/>Thank you for your registration, please click on the below link to comlete your registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>", user.Username, Url.Action("ConfirmEmail", "Account", new { Token = user.Id, Email = user.Email }, Request.Url.Scheme));
                    m.IsBodyHtml = true;
                    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.google.com");
                    smtp.Port = 587;
                    smtp.EnableSsl = true;
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials = new System.Net.NetworkCredential("email@gmail.com", password);

                    smtp.Send(m);

我禁用了我的防病毒软件并尝试了但都失败了。请问哪里出错了?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

检查端口/防火墙/防病毒软件,同时更改安全apps设置。