0
我已经张贴了我的来源,已经porblem名为邮件在MVC不发送3
连接尝试失败,因为连接的方没有正确一段时间后响应或已建立的连接失败,因为连接的主机没有回应68.178.232.62:25
我已经通过
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");
}
EmailManager
[System.Web.Services.WebMethod]
public static void SendMessage(string Position, string txtname, string fromEmail)
{
const string SERVER = "relay-hosting.secureserver.net";
const string TOEMAIL = "[email protected]";
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);
}
}
*连接的主机未能响应68.178.232.62:25*错误是显而易见的,因为网络连接不能建立。港口是否开放? – Raptor
对不起,新的mvc ..你可以请告诉我如何检查端口是否打开.. @Raptor – Rakyir
这是**没有**相关的代码。请使用telnet来诊断网络连接。搜索Google。 – Raptor