haku Posted July 22, 2010 Share Posted July 22, 2010 I'm trying to open a socket to an SMTP server. I am using the following code: $smtp_connect = fsockopen($node->smtp_server, $node->smtp_port, $errno, $errstr, 10); while (!feof($smtp_connect)) { $smtp_response .= fgets($smtp_connect, 4096); } echo $smtp_response; In my php.ini, I set default_socket_timeout to 10 seconds. I am also setting it explicitly in the function call. However, the fsocketopen function doesn't seem to close properly. I say this because when I take a timestamp at before the function call, and then again after the function call, the call itself takes 60 seconds. The response I get from th server (through fgets()) is the following: 220-<SMTP HOST> ESMTP Exim 4.69 #1 Thu, 22 Jul 2010 00:15:44 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. 421 <SMTP HOST>: SMTP command timeout - closing connection So the connection is made (which is why I get the 220 response), but then because it doesn't end the function call after the connection is made, it times out. Does anyone have any idea how to fix this? How can I force the function to stop after the socket has been opened successfully? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.