【问题标题】:A connection attempt failed -- Smtp.Send in asp.net mvc连接尝试失败--asp.net mvc 中的 Smtp.Send
【发布时间】:2015-03-28 07:39:04
【问题描述】:

我已经尝试发送消息有一段时间了。但是 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);

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

【问题讨论】:

  • 您的邮件服务器似乎有超时问题。你又试过了吗?
  • 尝试更改端口号或使用其他 smtp 服务器,如 Outlook
  • 尝试使用这些凭据远程登录到您的邮件服务器,以确保没有连接问题。
  • @Tommassiov 尚未托管。我在 IIS 和 VS 上运行。还是我必须先主持?

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


【解决方案1】:

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

【讨论】:

  • 它在更改应用程序设置后工作。我认为那对我有用。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-03-26
  • 1970-01-01
  • 1970-01-01
  • 2022-11-16
  • 1970-01-01
  • 2016-12-07
相关资源
最近更新 更多