0
votes

The following code is mine and works in my machine (Windows 7):

var fromAddress = "[email protected]";
var toAddress = "[email protected]";
const string fromPassword = "dfdfdf";
string subject = "Test Mail Please ignore";
string body = "Test";
body += "Email: ";
body += "Subject: ";
body += "Question:";
var smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "QAsmtp.company.net";
smtp.Port = 25;
//'smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential("csweb123lab", fromPassword);
smtp.Timeout = 300000;
smtp.Send(fromAddress, toAddress, subject, body);

I copied this code and run into my remote machine Windows 2008 R2 SP1 (64bit) that is also in the company network.

I am getting the below error message :

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

I pinged SMTP host response from this machine and its responding properly. I don't understand why I get this error frequently.

1
Team , anyone can help me to resolve this issue. its working in my machine. if i run the same code in remote machine. I am getting timeout error sometime i am getting unable to connnect server.user3442289

1 Answers

0
votes

Sounds like firewall to me. Even if ping works, you may have port 25 blocked. Use telnet to test if the port is open from a DOS command line like this:

telnet QAsmtp.company.net 25