469,646 Members | 1,305 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

fsockopen and gmail timeout mystery

103 100+
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_execution_time',150);
$security=array('tls','ssl');
$ports=array(465,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($host,$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:

Expand|Select|Wrap|Line Numbers
  1. Testing SSL and TLS connections to gmail.com
  2. 1
  3. Connected using tls and port 465
  4. 2
  5. Connected using tls and port 587
  6. 3
  7. Connected using ssl and port 465
  8. 4
  9.  
  10. ( ! ) Warning: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:func(119):reason(252)
  11. ( ! ) Warning: fsockopen() [function.fsockopen]: Failed to enable crypto
  12. ( ! ) Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:587 (Unknown error)
  13.  
Live server output:

Expand|Select|Wrap|Line Numbers
  1. Testing SSL and TLS connections to gmail.com
  2. 1
  3. Using tls and port 465 caused an error (110):
  4. Connection timed out
  5. 2
  6. Using tls and port 587 caused an error (110):
  7. Connection timed out
  8. 3
  9. Using ssl and port 465 caused an error (110):
  10. Connection timed out
  11. 4
  12. Using ssl and port 587 caused an error (110):
  13. Connection timed out
  14. Done
  15.  
Jun 27 '08 #1
6 5666
pbmods
5,821 Expert 4TB
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?
Jul 6 '08 #2
henryrhenryr
103 100+
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
Jul 15 '08 #3
pbmods
5,821 Expert 4TB
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.
Jul 16 '08 #4
henryrhenryr
103 100+
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...
Jul 17 '08 #5
henryrhenryr
103 100+
Yes, it was being blocked by the web-host's firewall.

Thanks for tips!

Henry
Jul 28 '08 #6
pbmods
5,821 Expert 4TB
Phew, that was a tricky one!

Glad you got it working. Good luck with your project!
Jul 28 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by DesignGuy | last post: by
9 posts views Thread by fipaj1992 | last post: by
1 post views Thread by yawnmoth | last post: by
2 posts views Thread by mydejamail | last post: by
1 post views Thread by Syl | last post: by
5 posts views Thread by webbyfoot | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.