0

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.

Gabriel Solomon
  • 29,065
  • 15
  • 57
  • 79
  • What mail server are you connecting to? Most residential ISPs disallow outgoing port 25 connections to any server other than their own. Try changing the outgoing server to be your ISP's SMTP server. – Craig Sep 10 '09 at 15:18
  • Are you able to use an MUA (thunderbird/outlook/mail.app) to send emails through it? – Shoan Sep 15 '09 at 02:17
  • 1
    I had this problem with `fsockopen` where the host had multiple IPs. I could telnet/swaks to the same hostname no problem, but fsockopen always timed out. By using `gethostfromname()` and then using the IP directly, `fsockopen` was much happier and did not time out. Very strange. – artfulrobot Dec 11 '14 at 10:48
  • check it out here http://codingbin.com/connection-timeout-error-php/ – Manoj Dhiman Jun 07 '17 at 07:16

1 Answers1

2

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 :

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.

Pascal MARTIN
  • 395,085
  • 80
  • 655
  • 663