System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 143.95.249.134:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, 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) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, 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(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) 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 ASP.email_csharp_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer)

Code:


<% @Page Language="C#" %>
<% @Import Namespace="System.Net.Mail" %>
<%

System.Net.Mail.MailMessage eMail = new System.Net.Mail.MailMessage();
eMail.IsBodyHtml = true;
eMail.Body = "body";
eMail.From = new System.Net.Mail.MailAddress("website@awtmach.com");
eMail.To.Add("leigh.glaus@gmail.com");
eMail.Subject = "subject";
System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient();
SMTP.Credentials = new System.Net.NetworkCredential("website@awtmach.com","Glaus101");
//SMTP.Host = "localhost";
SMTP.Host = "mail.awtmach.com";

try
	{
 		SMTP.Send(eMail); 
	}

catch (Exception ex)
	{
		string sMsg = ex.ToString();
		Response.Write(sMsg);
	}
 
%>