For some reason i keep having this error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at WUC_EmailContactUsForm.LinkButton1_Click(Object sender, EventArgs e)
Here is my code:
protected void LinkButton1_Click(object sender, EventArgs e)
{
MailMessage message = new MailMessage("webmaster@my-tribe.net", "jonathan@my-tribe.net");
Label AdditionalInfos = new Label();message.IsBodyHtml = true;
message.Body = tbMessage.Text +
"<br />" + AdditionalInfos.Text + "<br /> Sent on: " + System.DateTime.Today.Date.ToShortDateString() + " at: " + System.DateTime.Today.TimeOfDay.ToString();AdditionalInfos.Text = "A Reply may neet to be send to" + tbEmail.Text + "<br /> Filled under: " + ddl.SelectedValue + "<br/> <br/>";
SmtpClient Client = new SmtpClient("relay-hosting.secureserver.net", 587);Client.EnableSsl = true;
Client.UseDefaultCredentials =
false;Client.Credentials = new System.Net.NetworkCredential("webmaster@my-tribe.net", "Password");
try
{
Client.Send(message);
}
catch (Exception error)
{
Response.Write("Email send failed, Please try again!<br />" +error);
}
Thx