问题
I am running a local apache server on an ubuntu machine, and i am trying to use the phpmailer class to send mail. It tries to connect by fsockopen to the mail server, but it throws a timeout error. I tried setting the timeout to 15sec with no luck. It does work on other machines.
How can i find out if my ISP has blocked requests ? The mail server responds to ping.
回答1:
ping and SMTP command don't go via the same port ; it is possible that one port is opened, and not the other one.
If there is a timeout, it probably means that :
- either your SMTP server is not accepting connections from your server
- or there is something somewhere (like a firewall) that's blocking your requests.
If you have an ssh access to the server, using telnet in command line to try to connect to the SMTP server, and send SMTP commands, might allow you to get some more informations...
Here a couple of links that show examples of an SMTP session via telnet :
- Sending an e-mail via Telnet
- Send mail through SMTP using Telnet
If you cannot connect to the server, maybe you'll get some error message (telling you that you are not allowed to connect, for instance), or it'll timeout again... Which probably means your request are being blocked somewhere...
In that case, check with your network administrator ; maybe he'll have some idea about opening some port on the firewall.
来源:https://stackoverflow.com/questions/1400733/php-fsockopen-unable-to-connect-connection-timeout-error