简体   繁体   中英

Can't Telnet to SMTP server on port 25 but PHP mail() works

Not having found any answers to this question: PHP mail() function from inside VMWare virtual machine (Win7)

I have decided to try something new. I set up an SMTP relay on a machine. I can use it and receive mail inside its spooling directory just fine. However when I try to set it up to forward mail to an already configured SMTP server (called "mail", at port 25) it fails.

Telnet also fails on port 25, so it seems normal that it wouldn't work - "Connection refused" is the error from telnet.

But the really strange thing is that if I set up an Apache/PHP server on this machine and use the mail function of PHP (configured to connect to "mail" at port 25) it works! I can send emails from PHP (which I don't need) but I can't telnet to the machine.

Anyone ever see something like this? It's driving me crazy!

Thanks in advance

Have you checked the firewall settings? If your firewall isn't allowing connections from external addresses to port 25, but is allowing local connections to port 25, then that'd explain why PHP can use it just fine but you can't connect from the outside.

Have you tried to use the ip address of "mail" instead of the hostname.

Network devices on Win 7 use ipv4 and ipv6 by default. If you specify the computername (not the DNS entry of the machine) while opening a connection (ie starting telnet) than "mail" may be resolved to either the ipv4 or the ipv6 address of that machine (more or less) at random. If your mailserver does only listen on the ipv4 address, you won't get a connection when "mail" is resolved.

You can observe the same problem, when the machine "mail" has more then one network devices. Then it may resolve the computername to either of the addresses of the network devices.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM