fsockopen and gmail timeout mystery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • henryrhenryr
    New Member
    • Jun 2007
    • 103

    fsockopen and gmail timeout mystery

    Hi

    I'm really hoping for some ideas!

    I have been setting up phpmailer on my server and it was working nicely on my local server so I uploaded to my live server and tested. The mystery is that it times out.

    The timeout occurs with fsockopen(). I have checked the php configuration line by line and I can't find anything in the live server setup that is different from the local which might affect it. Could gmail have black-listed my domain/server or something?

    Here is my test code and the output - first from the local server and second from the live. You can see the difference. Any clues?!

    Thanks in advance!!!

    [PHP]
    <?php
    echo '<h1>Testing SSL and TLS connections to gmail.com</h1>';
    ini_set('max_ex ecution_time',1 50);
    $security=array ('tls','ssl');
    $ports=array(46 5,587);

    $c=0;
    foreach ($security as $suf) {
    foreach ($ports as $p) {
    ++$c;
    echo "<h3>$c</h3>";
    $host= ($suf=='ssl') ? "$suf://smtp.gmail.com" : "smtp.gmail.com ";
    if (fsockopen($hos t,$p,$errorno,$ errormsg,10)) {
    echo "Connected using $suf and port $p";
    }
    else {
    echo "Using $suf and port $p caused an error ($errorno): <br />$errormsg<hr /><hr />";
    }
    }
    }

    echo "Done";

    ?>
    [/PHP]

    Local server output:

    [code=text]
    Testing SSL and TLS connections to gmail.com
    1
    Connected using tls and port 465
    2
    Connected using tls and port 587
    3
    Connected using ssl and port 465
    4

    ( ! ) Warning: fsockopen() [function.fsocko pen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC: SSL routines:func(1 19):reason(252)
    ( ! ) Warning: fsockopen() [function.fsocko pen]: Failed to enable crypto
    ( ! ) Warning: fsockopen() [function.fsocko pen]: unable to connect to ssl://smtp.gmail.com: 587 (Unknown error)
    [/code]

    Live server output:

    [code=text]
    Testing SSL and TLS connections to gmail.com
    1
    Using tls and port 465 caused an error (110):
    Connection timed out
    2
    Using tls and port 587 caused an error (110):
    Connection timed out
    3
    Using ssl and port 465 caused an error (110):
    Connection timed out
    4
    Using ssl and port 587 caused an error (110):
    Connection timed out
    Done
    [/code]
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Henry.

    How long does it take for the connection to timeout? Does it take the full 10 seconds, or does it happen right away?

    Comment

    • henryrhenryr
      New Member
      • Jun 2007
      • 103

      #3
      Hi

      The timeout always occurs at the maximum set by the the various timeout variables. I have tried setting the timeout up to 2 minutes and still after 2 minutes it reports the same output.

      Is this good or bad?!

      Thanks for replying!

      Henry

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Are you unable to connect to any server, or is it just Gmail?

        I wonder if you're being firewalled. Either Gmail is blocking connections from your live host for some reason, or else your live host isn't allowing outgoing connections.

        I'd check with your hosting provider to make sure they allow what you're trying to accomplish.

        Comment

        • henryrhenryr
          New Member
          • Jun 2007
          • 103

          #5
          Hi pbmods

          Good idea! Why didn't I think of that... I have asked my host, we'll see... It's a shared host, I suppose someone else might have 'abused' the friendly gmail smtp service and got the whole server blocked...

          Comment

          • henryrhenryr
            New Member
            • Jun 2007
            • 103

            #6
            Yes, it was being blocked by the web-host's firewall.

            Thanks for tips!

            Henry

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              Phew, that was a tricky one!

              Glad you got it working. Good luck with your project!

              Comment

              Working...