【发布时间】:2016-05-01 06:18:36
【问题描述】:
我已经发布了我的源代码,该资源名为
连接尝试失败,因为连接的一方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应 68.178.232.62:25
我已经通过 ref 实现了
http://developmentfaction.blogspot.in/2013/03/sending-email-with-javascript-and-aspnet.html
请帮我解决这个问题
提前感谢:)
查看页面
@using (Html.BeginForm("Emailto", "Home", FormMethod.Post))
{
@Html.TextBoxFor(a => a.Position, new { @readonly = "readonly", @id = "Position", @name = "Position" })
<input type="text" value="" id="txtname" name="txtname" required />
<input type="email" value="" id="txtemail" name="fromEmail" required />
<input type="submit" id="btnApply" name="btnApply" value="Apply" />
控制器
[HttpPost, ValidateInput(false)]
public ActionResult Emailto(string Position, string txtname, string fromEmail)
{
EmailManager.SendMessage(Position, txtname, fromEmail);
return Redirect("Index");
}
电子邮件管理器
[System.Web.Services.WebMethod]
public static void SendMessage(string Position, string txtname, string fromEmail)
{
const string SERVER = "relay-hosting.secureserver.net";
const string TOEMAIL = "acb@gmail.com";
MailAddress from = new MailAddress(fromEmail);
MailAddress to = new MailAddress(TOEMAIL);
MailMessage message = new MailMessage(from, to);
message.Subject = "Position " + Position;
message.Body = "Message from: " + Position + " at " +
fromEmail + "\n\n" + txtname;
message.IsBodyHtml = false;
SmtpClient client = new SmtpClient(SERVER);
client.Send(message);
}
}
【问题讨论】:
-
connected host has failed to respond 68.178.232.62:25 错误很明显,无法建立网络连接。端口开放了吗?
-
对不起,我是 mvc 的新手.. 你能告诉我如何检查端口是否打开.. @Raptor
-
它与代码不相关。请使用
telnet诊断网络连接。搜索谷歌。 -
您是否配置了
SmtpClient的凭据和端口。 -
不,需要为 SmtpClient 配置凭据! @MahbuburRahman
标签: asp.net-mvc-3 email