I have one web application which hosted on Godaddy server. I am stuck with Failure sending mail error. I place my code here
public void Mailing()
{
MailMess
I faced the same problem when I say my previous C# working code (that was sending emails using Godaddy server) wasn't sending emails anymore. So I spend 5 hours to find the actual problem
The problem is that Godaddy changed the settings on their servers. Due to this you won't be able to send email using:
I solved this by doing 2 things:
Used SmtpClient Host as "relay-hosting.secureserver.net".
Put my web page on my Godaddy shared server (as localhost will still not able to send smtp email due to security added by Godaddy).
This is the correct working code from my side:
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("test@yourdomain.com");
mailMessage.To.Add(new MailAddress("senderemail@gmail.com"));
mailMessage.Subject = "hello";
mailMessage.IsBodyHtml = true;
mailMessage.Body = "hello how are you";
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("test@yourdomain.com", "yourpassword");
client.Host = "relay-hosting.secureserver.net";
client.Send(mailMessage);
In the above code see how I added the host:
client.Host = "relay-hosting.secureserver.net";
The mail will reach you in 25 to 30 seconds time. If you still can't find the email kindly check your spam folder.
Proof
At the time of writing this answer I tested my code and found the send email to my Gmail Inbox. See the below image as a proof:
Check the code below. You have to change client.Host = "smtpout.secureserver.net."
MailMessage msg = new MailMessage(txtemail.Text, "shopover@vibrantinfosystems.com");
msg.Subject = "Contact Us";
string body = "Name: " + txtname.Text.Trim() + "";
body += "<br />Email:" + txtemail.Text + "";
body += "<br /><br /> Subject :" + txtsubject.Text + "";
body += "<br /><br />Message : " + txtmessage.Text + "";
msg.Body = body;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Host = "smtpout.secureserver.net.";
client.Send(msg);
client.Timeout = 10000;
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Mail Sent Successfully!!');", true);
EnableSsl
should be true.
If you need a timeout then its property should be set before the email is sent try adjusting like this
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "relay-hosting.secureserver.net";
smtpClient.Port = 465;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials =
new NetworkCredential("mailadress@server.net", "Password");
...
smtpClient.Timeout = 10000;
smtpClient.Send(message);