"Connection to host lost" on telnet to port 25

12,457

As previously discussed in the comments, I am writing this answer for others who may come across this problem.

Adding a Windows Firewall rule to open port 25 will rectify this problem as the connection was rejecting the connection thus not allowing telnet to establish.

Share:
12,457

Related videos on Youtube

WhiteOne
Author by

WhiteOne

Updated on September 18, 2022

Comments

  • WhiteOne
    WhiteOne over 1 year

    i installed smtp4dev to test receive mails in my localserver(xampp) for the registration form here: https://github.com/panique/php-login

    note: localserver is on port: 8080

    my php.ini file for SMTP section is as follows and the smtp is activated as that was shown in xampp status:

    [mail function]
    SMTP = localhost
    smtp_port = 25
    sendmail_from = postmaster@localhost
    sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
    sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
    ;mail.log = "C:\xampp\php\logs\php_mail.log"
    

    but i didn't receive any email, so i checked the smtp if it worked via telnet:

    telnet localhost 25
    

    and i get this after running telnet command:

    220 localhost smtp4dev ready
    
    
    Connection to host lost.
    

    how can i solve this problem?

    • Proxy
      Proxy over 9 years
      Is the port open and accepting connections?
    • WhiteOne
      WhiteOne over 9 years
      port 25 status is Time_wait how can i make it listening? i think this the problem right?
    • Proxy
      Proxy over 9 years
      On Windows you will have to create an firewall rule to explicity allow the port. On Linux you will have to iptables command to add the port to Accept connections. To open a port in issue: iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
    • WhiteOne
      WhiteOne over 9 years
      i'm on windows, when i add firewall rule for port 25 do i need to enable it for public also or just private? i will use smtp4dev for my local host only as a test.
    • Proxy
      Proxy over 9 years
      That depends solely on your network configuration and if you need public access to it. In most cases, you only need to use Private, but you can apply both to see if the problem rectifies and de-select 'public' in the rule at a later stage. Personally, I'd just Private.
    • WhiteOne
      WhiteOne over 9 years
      okay :) thanks a lot :) that solved my problem when i add a rule for port 25 in firewall settings.