SMTP Mail Error->"Unable to connect to the remote server


  • I've seen this problem everywhere searching...but haven't been able to resolve it.

    • I have created a simple console application to test smtp on a WinXP Pro box.
    • First I enabled port 25, then I just disabled the Windows firewall altogether.
    • There is no McAffee installed that would block the port.
    • I also attempted to telnet and was refused.
    • I ping the mail server and it responds correctly

    Here's the code sample..

    static void Main(string[] args)
                MailMessage msg = new MailMessage("", "", "test", "This is a test");
                SmtpClient client = new SmtpClient("");
    System.Net.NetworkCredential("user", "pass");
    System.Net.NetworkCredential cred = new NetworkCredential("user", "pass");
    client.Credentials = CredentialCache.DefaultNetworkCredentials;
                { client.Send(msg); }
                catch (SmtpException ex)

    Here's the error it throws:

    {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 123.45.789.123:25
       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 mailTest.Program.Main(String[] args) in C:\mailTest\mailTest\mailTest\Program.cs:line 25}

    I'm at a loss.


    • Edited by drdexter33 Friday, August 2, 2013 9:22 PM
    Friday, August 2, 2013 9:22 PM


  • McAfee was blocking port 25.

    Got admin rights and disabled mass emailing setting.

    Thanks everyone.

    • Marked as answer by drdexter33 Tuesday, August 13, 2013 4:32 PM
    Tuesday, August 13, 2013 4:32 PM

All replies