php fsockopen unable to connect, connection timeout error

╄→尐↘猪︶ㄣ 提交于 2020-01-14 05:49:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!