邮件未在 mvc 3 中发送
Mail not sending in mvc 3
我已经发布了我的来源,其中有一个名为
的问题
连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应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);
}
}
您似乎没有为 smtp 提供密码或端口。
var loginInfo = new NetworkCredential(email, password);
SmtpClient client = new SmtpClient(SERVER, 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(mail);
希望对您有所帮助
我已经发布了我的来源,其中有一个名为
的问题连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应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);
}
}
您似乎没有为 smtp 提供密码或端口。
var loginInfo = new NetworkCredential(email, password);
SmtpClient client = new SmtpClient(SERVER, 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(mail);
希望对您有所帮助