Contact page SMTP code is refused connection to mail server

Discussion in 'Site Programming, Development and Design' started by gort79, May 3, 2012.

  1. Hello,

    I've built a simple "contact us" page, but for some reason, the SMTP client is being refused access to the mail server. I've enabled SMTP for our site, double checked all of the posts in your knowledge base and forums, and by all accounts, this should work. Here's what I have:


    var client = new SmtpClient("mail.wordcandy.net");
    var creds = new NetworkCredential("[email protected]", "MyPassword");
    client.Credentials = creds;
    var mail = new MailMessage(contact.YourEmailAddress, "[email protected]", contact.Subject, contact.Body);
    client.Send(mail);

    And here's the error message I get:

    No connection could be made because the target machine actively refused it 64.79.170.149:21

    I've tried telneting into that address with no luck. I've tried port 25, too. No luck. That IP does resolve to my mail server. Does your mail server just hate me or something? If so, I'm so hurt. If not, please let me know what I'm doing wrong.

    Thanks!

    Sincerely,
    Nathan
     
  2. ComputerMan

    ComputerMan Winhost Staff

    Are you really using the above credentials to pass through the SMTP authentication process? Or are you using your real email address?

    Also, try using the postmaster email account to authenticate against the SMTP service to see if that works.

    Please read our knowledge base article on How to send email in ASP.NET

    I also notice the error message your getting "No connection could be made because the target machine actively refused it 64.79.170.149:21" We don't allow connections on port 21 for the mail server. If you web application is trying to connect to port 21 change it to port 25 or 587.

    "I've tried telneting into that address with no luck. I've tried port 25, too. No luck."

    I've telneted to the address: mail.wordcandy.net on port 25 just fine on my end. The email server does respond. Are you trying to do this on your local computer? Try telneting on port 587 to see if that works.
     
    Last edited by a moderator: Oct 14, 2015

Share This Page