When I remove the comment "//stmp.timeout" it gives timeout error. What should I do to fix that?
Here is my code:
public ActionResult Index(EmailModel model)
{
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 180;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential("sheikh.abm@gmail.com ","somepassword");
//smtp.Timeout = 20000;
}
try
{
smtp.Send("sheikh.abm@gmail.com",model.To, model.Subject, model.Message);
return View("Index");
}
catch (Exception ex)
{
Console.WriteLine(ex); //Should print stacktrace + details of inner exception
if (ex.InnerException != null)
{
Console.WriteLine("InnerException is: {0}", ex.InnerException);
}
}
return View("Index");