I am trying to send a mail via goDaddy mail server. The mail is being sent (I am receiving it in my mailbox) but the catch block is executing and landing me to the contact page with querystring msg as "fail"
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["username"] != null && Request.QueryString["email"] != null && Request.QueryString["msg"] != null) { try { string name = Request.QueryString[0]; string email = Request.QueryString[1]; string msg = Request.QueryString[2]; SmtpClient smtp = new SmtpClient("relay-hosting.secureserver.net", 25); //smtp.EnableSsl = false; smtp.Send("[email protected]", "[email protected]", "feedback", "Name:" + name + "\n e-mail:" + email + "\n Subject:" + msg); Response.Redirect("contact.html?msg=success"); } catch(Exception ex) { Response.Redirect("contact.html?msg=fail"); } } else { Response.Redirect("contact.html"); } } If the mail is being sent, shouldn't it redirect to "contact.html?msg=success"?
catchblock won't execute if there is no exception