ERROR: Unable to connect to the remote server...

Discussion in 'Email' started by PRRabbitt, Aug 4, 2012.

  1. I have set up my ASP.NET application to use Winhost’s smtp server, and the email works fine from home when using localhost, but as soon as it is deployed to Winhost it no longer works with the following Exception:

    Exception: Failure sending mail.
    Inner Exception: Unable to connect to the remote server

    The error Unable to connect to the remote server is typical when the IP is not resolving properly (as I found out when I originally tried using the Winhost web server instead of the mail server!)

    However, I have had a couple of friends in different places on the globe ping my smtp name (e.g. mail.MY_DOMAIN.com) and it resolves correctly to Winhosts mail server.

    Is there a chance that Winhost DNS has not flushed and it is still resolving to the old IP? In which case, maybe it's just a waiting game.
    Otherwise if anyone has any advice it would be appreciated.

    Many thanks
     
    Last edited by a moderator: Oct 14, 2015
  2. ComputerMan

    ComputerMan Winhost Staff

    If you are testing the web application locally on your computer and then you have it set to use our SMTP service. Your ISP might be blocking port 25 and you may not even know it. Try using our alternative port 587 to see if that resolves your issue.

    Also,

    Make sure you are authenticating against the SMTP services for our mail server.

    Please read our knowledge base article on How to send email in ASP.NET
     
    Last edited by a moderator: Oct 14, 2015
  3. Many thanks ComputerMan, but as I mentioned in the opening post, it works fine locally, it's when I upload the web application to Winhost that it no longer works. So my home ISP doesn't really come into it.

    I have however tried both ports 25 & 587 but to no avail. I am also authenticating against SMTP.

    I have supplied the code below just to clarify what I have already done:
     
    Last edited by a moderator: Oct 14, 2015
  4. As I mentioned in my opening post:

    I can confirm it is now working. So I suspect it was simply a matter of the DNS Winhost depends upon taking a bit longer to update.

    So this issue is now resolved.

    Thanks
     
    Last edited by a moderator: Oct 14, 2015
  5. I have the same problem. The code below:

    Code:
    using (var client = new SmtpClient("mail.kekely.com")) {
        client.Port = 25 // also I tried with 587;
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.EnableSsl = false;
        client.UseDefaultCredentials = false;
        client.Credentials = 
            new NetworkCredential("postmaster@kekely.com, "mypassword");
    
        try {
            client.Send(My_Message_Goes_Here);
        } catch (ArgumentNullException) {
            throw;
        } catch (ObjectDisposedException) {
            throw;
        } catch (InvalidOperationException) {
            throw;
        } catch (SmtpFailedRecipientsException) {
            throw;
        } catch (SmtpException) {
            // I get an SmtpException error
            throw;
        } catch (Exception) {
            throw;
        }
    }
    works fine on my local computer and using port = 587
    But when I upload the application to the server, the `SmtpException` occurs when I try to send an email. Do you have any suggestion?
     
  6. ComputerMan

    ComputerMan Winhost Staff

    I believed we already answered your issue through our ticketing system and on our other forum post here: http://forum.Winhost.com/showthread.php?t=11882

    The issue you had was related to a wrong A record pointing to a different mail server that didn't belong to us. Or I believe it was CNAME. Either way you stated on the ticket that you've resolved your issue after you set up the correct A Record.
     
    Last edited by a moderator: Oct 14, 2015

Share This Page