Hi, here's the site I'm currently working on:
http://www.johnernaut.com
Under the 'contact' tab I have some behind the scenes C# code that SHOULD send me an email whenever the submit button is pressed and all fields are validated. This isn't working for some reason. The host I'm using is GoDaddy. I've looked up the smtp host / port and it should be working fine, but it's not. Here's my code:
protected void SendMail()
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress(txtEmail.Text);
mail.To.Add("myemail@gmail.com");
mail.Subject = "Contact Me";
mail.IsBodyHtml = true;
mail.Body = "From: " + txtName.Text + "<br />";
mail.Body += "Email: " + txtEmail.Text + "<br />";
mail.Body += "Comments: " + txtComments.Text + "<br />";
mail.Priority = MailPriority.Normal;
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("godaddy_email_username", "godaddy_email_password");
client.Host = "relay-hosting.secureserver.net";
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(mail);
}
protected void Reset()
{
txtName.Text = "";
txtEmail.Text = "";
txtComments.Text = "";
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
SendMail();
}
catch (Exception) { }
Reset();
}
I'm not getting an email. Any help would be appreciated, thank you.