By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,858 Members | 1,353 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,858 IT Pros & Developers. It's quick & easy.

fsockopen and gmail timeout mystery

P: 103

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!!!

echo '<h1>Testing SSL and TLS connections to</h1>';

foreach ($security as $suf) {
foreach ($ports as $p) {
echo "<h3>$c</h3>";
$host= ($suf=='ssl') ? "$suf://" : "";
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";


Local server output:

Expand|Select|Wrap|Line Numbers
  1. Testing SSL and TLS connections to
  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
  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:// (Unknown error)
Live server output:

Expand|Select|Wrap|Line Numbers
  1. Testing SSL and TLS connections to
  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
Jun 27 '08 #1
Share this Question
Share on Google+
6 Replies

Expert 5K+
P: 5,821
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

P: 103

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!

Jul 15 '08 #3

Expert 5K+
P: 5,821
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

P: 103
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

P: 103
Yes, it was being blocked by the web-host's firewall.

Thanks for tips!

Jul 28 '08 #6

Expert 5K+
P: 5,821
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.