【发布时间】: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