Hello fellow Godaddy users,
I am hoping someone can help me find a solution to sending email from a simple "contact us" web page with Godaddy hosting. Other people have found a solution, however I have not. Below is the code I have used in a test page for sending email with Gmail, so I know that the code works. I also know that for it to work with Godaddy hosting, I need to change some settings. Such as: network host to "relay-hosting.secureserver.net". I have attempted coding both with and without "username" and "password"; with and without "port" to no avail. Would a fellow Godaddy hoster please inform me with what has worked for them?
Page code:
<%@ import namespace="System.Net" %>
<%@ import namespace="System.Net.Mail" %>
<script runat="server">
protected void btnSubmit_Click(object sender, EventArgs e)
{
MailMessage myMail = new MailMessage();
SmtpClient smtp = new SmtpClient();
myMail.From = new MailAddress("xxxxx@gmail.com");
myMail.Subject = "contact form";
MailAddressCollection myMailTo = new MailAddressCollection();
myMail.To.Add("xxxxx@gmail.com");
StringBuilder sb = new StringBuilder();
sb.Append("Name: " + txtName.Text + "<br>");
sb.Append("Email Address: " + txtUserEmail.Text + "<br>");
sb.Append("Comments: " + txtComments.Text + "<br>");
string strBody = sb.ToString();
myMail.Body = strBody;
myMail.IsBodyHtml = true;
smtp.EnableSsl = true;
try
{
smtp.Send(myMail);
myMail = null;
}
catch (System.Exception ex)
{
Response.Write(ex.Message);
}
}
</script>
Web.config
<system.net>
<mailSettings>
<smtp from="">
<network host="smtp.gmail.com" password="xxxxxx" port="587"
userName="xxxxx@gmail.com" />
</smtp>
</mailSettings>
</system.net>