Community Discussions and Support
PHP time out waiting for response from Mercury

This is a common problem. You need to tell the socket stack not re-use the socket, f.ex. by setting the socket idle timout on your session to a very low value (like 1 second).

This is what it looks like when coding C# in .NET

MailMessage msgMail = new MailMessage(); 

msgMail.To.Add("address");

msgMail.Body = "test";

SmtpClient Client = new SmtpClient(); /* uses settings from web.config */

Client.ServicePoint.MaxIdleTime = 1; /* without this the connection is idle too long */

Client.Send(msgMail);

msgMail.Dispose();

<P>This is a common problem. You need to tell the socket stack not re-use the socket, f.ex. by setting the socket idle timout on your session to a very low value (like 1 second).</P> <P>This is what it looks like when coding C# in .NET</P><PRE>MailMessage msgMail = new MailMessage(); msgMail.To.Add("address"); msgMail.Body = "test"; SmtpClient Client = new SmtpClient(); /* uses settings from web.config */ Client.ServicePoint.MaxIdleTime = 1; /* without this the connection is idle too long */ Client.Send(msgMail); msgMail.Dispose(); </PRE>

Hi

 I have been setting up a web page, WWW and mail server using the Xampp package. So far I have been able to overcome all my inexperience with the help of guides and what not, but have walked in to something I dont find any answer to.

My one PHP script requires e-mail verification, and I use PHPmailer through Mercury for that. I set up Mercury to use my Gmail, and everything works just fine, except for a communication gap between Mercury and PHPmailer.

I submit registration details and after a while I get :

 

Warning: fsockopen() [function.fsockopen]:

unable to connect to :25 (A connection attempt failed because the

connected party did not properly respond after a period of time, or

established connection failed because connected host has failed to

respond.

) in C:\Inetpub\PhP and Sql\xampp\htdocs\class.smtp.php on line 122

 

1. I changed the time-out in the PHPscript to 60 seconds even, but no luck.

2. The process completes successfully though, and I get my mail in Gmail without any problems.

 T 20100130 024535 4b639d11 Connection from 127.0.0.1
T 20100130 024535 4b639d11 HELO danie
T 20100130 024535 4b639d11 MAIL FROM:<postmaster@localhost>
T 20100130 024535 4b639d11 RCPT TO:<7fatcowsinfo@gmail.com>
T 20100130 024535 4b639d11 DATA
T 20100130 024535 4b639d11 DATA - 29 lines, 661 bytes.
T 20100130 024535 4b639d11 QUIT
T 20100130 024535 4b639d11 Connection closed with 127.0.0.1, 0 sec. elapsed.
 

Is there some setting in Mercury that I need to set in order for it to acknowledge to the script that the process was successful ? Or am I missing something else completely ? 

&lt;p&gt;Hi&lt;/p&gt;&lt;p&gt;&amp;nbsp;I have been setting up a web page, WWW and mail server using the Xampp package. So far I have been able to overcome all my inexperience with the help of guides and what not, but have walked in to something I dont find any answer to. &lt;/p&gt;&lt;p&gt;My one PHP script requires e-mail verification, and I use PHPmailer through Mercury for that. I set up Mercury to use my Gmail, and everything works just fine, except for a communication gap between Mercury and PHPmailer. &lt;/p&gt;I submit registration details and after a while I get :&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Warning&lt;/b&gt;: fsockopen() [&lt;a href=&quot;http://7fatcowsmobile.mooo.com/function.fsockopen&quot;&gt;function.fsockopen&lt;/a&gt;]: unable to connect to :25 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in &lt;b&gt;C:\Inetpub\PhP and Sql\xampp\htdocs\class.smtp.php&lt;/b&gt; on line &lt;b&gt;122&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;1. I changed the time-out in the PHPscript to 60 seconds even, but no luck.&lt;/p&gt;&lt;p&gt;2. The process completes successfully though, and I get my mail in Gmail without any problems. &lt;/p&gt;&lt;p&gt;&amp;nbsp;T 20100130 024535 4b639d11 Connection from 127.0.0.1 T 20100130 024535 4b639d11 HELO danie T 20100130 024535 4b639d11 MAIL FROM:&amp;lt;postmaster@localhost&amp;gt; T 20100130 024535 4b639d11 RCPT TO:&amp;lt;7fatcowsinfo@gmail.com&amp;gt; T 20100130 024535 4b639d11 DATA T 20100130 024535 4b639d11 DATA - 29 lines, 661 bytes. T 20100130 024535 4b639d11 QUIT T 20100130 024535 4b639d11 Connection closed with 127.0.0.1, 0 sec. elapsed. &amp;nbsp;&lt;/p&gt;&lt;p&gt;Is there some setting in Mercury that I need to set in order for it to acknowledge to the script that the process was successful ? Or am I missing something else completely ?&amp;nbsp; &lt;/p&gt;

That MercS log is completely normal and completes normally [:)], in under one second.

I have no idea what your script may be waiting for.

Turn on session logging for MercS to get a complete transcript that may provide more clues.

&lt;p&gt;That MercS log is completely normal and completes normally [:)], in under one second.&lt;/p&gt;&lt;p&gt;I have no idea what your script may be waiting for.&lt;/p&gt;&lt;p&gt;Turn on session logging for MercS to get a complete transcript that may provide more clues. &lt;/p&gt;

As requested :

 

03:18:25.343: Connection from 127.0.0.1, Sat Jan 30 03:18:25 2010<lf>
03:18:25.343: << 220-SMTP ESMTP server ready.<cr><lf>220-220-somehost.somedomain.com Mercury/32 v3.21 ESMTP server ready.<cr><lf>220-220-Use of this server for unauthorised relaying of mail is forbidden.<cr><lf>220 220 Unsolicited Commercial E-mail ("spam") is NOT WELCOME HERE.<cr><lf>
03:18:25.343: >> HELO danie<cr><lf>
03:18:25.343: << 250 SMTP Hello, danie.<cr><lf>
03:18:25.343: >> MAIL FROM:<postmaster@localhost><cr><lf>
03:18:25.343: << 250 Sender OK - send RCPTs.<cr><lf>
03:18:25.343: >> RCPT TO:<7fatcowsinfo@gmail.com><cr><lf>
03:18:25.343: << 250 Recipient OK - send RCPT or DATA.<cr><lf>
03:18:25.359: >> DATA<cr><lf>
03:18:25.359: << 354 OK, send data, end with CRLF.CRLF<cr><lf>
03:18:25.359: >> Date: Sat, 30 Jan 2010 03:18:25 +0200<cr><lf>
03:18:25.359: >> Subject: Login Details<cr><lf>
03:18:25.359: >> To: 7fatcowsinfo@gmail.com<cr><lf>
03:18:25.359: >> From: "Member Registration" <auto-reply@7fatcowsmobile.mooo.com><cr><lf>
03:18:25.359: >> X-Mailer: PHP/5.3.1<cr><lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> Thank you for registering with us. Here are your login details...<lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> User ID: l<cr><lf>
03:18:25.359: >> Email: 7fatcowsinfo@gmail.com <lf>
03:18:25.359: >>  <cr><lf>
03:18:25.359: >> Passwd:  <lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> Activation code: 3354 <lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> *****ACTIVATION LINK*****<lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> http://7fatcowsmobile.mooo.com/activate.php?user=32bb90e8976aab5298d5da10fe66f21d&activ_code=3354<cr><lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> Thank You<cr><lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> Administrator<cr><lf>
03:18:25.359: >> 7FATCOWSMOBILE.MOOO.COM<cr><lf>
03:18:25.359: >> ______________________________________________________<cr><lf>
03:18:25.359: >> THIS IS AN AUTOMATED RESPONSE. <cr><lf>
03:18:25.359: >> ***DO NOT RESPOND TO THIS EMAIL****<cr><lf>
03:18:25.359: >> <cr><lf>
03:18:25.359: >> .<cr><lf>
03:18:25.359: << 250 Data received OK.<cr><lf>
03:18:25.359: >> QUIT<cr><lf>
03:18:25.359: << 221 SMTP Service closing channel.<cr><lf>
03:18:25.359: --- Connection closed normally at Sat Jan 30 03:18:25 2010. ---
03:18:25.359:
 

&lt;p&gt;As requested :&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;03:18:25.343: Connection from 127.0.0.1, Sat Jan 30 03:18:25 2010&amp;lt;lf&amp;gt; 03:18:25.343: &amp;lt;&amp;lt; 220-SMTP ESMTP server ready.&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt;220-220-somehost.somedomain.com Mercury/32 v3.21 ESMTP server ready.&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt;220-220-Use of this server for unauthorised relaying of mail is forbidden.&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt;220 220 Unsolicited Commercial E-mail (&quot;spam&quot;) is NOT WELCOME HERE.&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.343: &amp;gt;&amp;gt; HELO danie&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.343: &amp;lt;&amp;lt; 250 SMTP Hello, danie.&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.343: &amp;gt;&amp;gt; MAIL FROM:&amp;lt;postmaster@localhost&amp;gt;&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.343: &amp;lt;&amp;lt; 250 Sender OK - send RCPTs.&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.343: &amp;gt;&amp;gt; RCPT TO:&amp;lt;7fatcowsinfo@gmail.com&amp;gt;&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.343: &amp;lt;&amp;lt; 250 Recipient OK - send RCPT or DATA.&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; DATA&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;lt;&amp;lt; 354 OK, send data, end with CRLF.CRLF&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; Date: Sat, 30 Jan 2010 03:18:25 +0200&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; Subject: Login Details&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; To: 7fatcowsinfo@gmail.com&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; From: &quot;Member Registration&quot; &amp;lt;auto-reply@7fatcowsmobile.mooo.com&amp;gt;&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; X-Mailer: PHP/5.3.1&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; Thank you for registering with us. Here are your login details...&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; User ID: l&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; Email: 7fatcowsinfo@gmail.com &amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt;&amp;nbsp; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; Passwd:&amp;nbsp; &amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; Activation code: 3354 &amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; *****ACTIVATION LINK*****&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; http://7fatcowsmobile.mooo.com/activate.php?user=32bb90e8976aab5298d5da10fe66f21d&amp;amp;activ_code=3354&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; Thank You&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; Administrator&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; 7FATCOWSMOBILE.MOOO.COM&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; ______________________________________________________&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; THIS IS AN AUTOMATED RESPONSE. &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; ***DO NOT RESPOND TO THIS EMAIL****&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; .&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;lt;&amp;lt; 250 Data received OK.&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;gt;&amp;gt; QUIT&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: &amp;lt;&amp;lt; 221 SMTP Service closing channel.&amp;lt;cr&amp;gt;&amp;lt;lf&amp;gt; 03:18:25.359: --- Connection closed normally at Sat Jan 30 03:18:25 2010. --- 03:18:25.359: &amp;nbsp;&lt;/p&gt;

This is the section of the code referred to by the error message

 

    #connect to the smtp server
    $this->smtp_conn = fsockopen($host,    # the host of the server
                                 $port,    # the port to use
                                 $errno,   # error number if any
                                 $errstr,  # error message if any
                                 $tval);   # give up after ? secs  <-------- line 122
    # verify we connected properly
    if(empty($this->smtp_conn)) {
      $this->error = array("error" => "Failed to connect to server",
                           "errno" => $errno,
                           "errstr" => $errstr);
      if($this->do_debug >= 1) {
        echo "SMTP -> ERROR: " . $this->error["error"] .
                 ": $errstr ($errno)" . $this->CRLF;
      }
      return false;
    }
 

&lt;p&gt;This is the section of the code referred to by the error message&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #connect to the smtp server &amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;smtp_conn = fsockopen($host,&amp;nbsp;&amp;nbsp;&amp;nbsp; # the host of the server &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $port,&amp;nbsp;&amp;nbsp;&amp;nbsp; # the port to use &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $errno,&amp;nbsp;&amp;nbsp; # error number if any &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $errstr,&amp;nbsp; # error message if any &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $tval);&amp;nbsp;&amp;nbsp; # give up after ? secs&amp;nbsp; &amp;lt;-------- line 122 &amp;nbsp;&amp;nbsp;&amp;nbsp; # verify we connected properly &amp;nbsp;&amp;nbsp;&amp;nbsp; if(empty($this-&amp;gt;smtp_conn)) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;error = array(&quot;error&quot; =&amp;gt; &quot;Failed to connect to server&quot;, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;errno&quot; =&amp;gt; $errno, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;errstr&quot; =&amp;gt; $errstr); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if($this-&amp;gt;do_debug &amp;gt;= 1) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;SMTP -&amp;gt; ERROR: &quot; . $this-&amp;gt;error[&quot;error&quot;] . &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;: $errstr ($errno)&quot; . $this-&amp;gt;CRLF; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&lt;/p&gt;

Again, perfectly normal.

From a Mercury perspective there is no problem.

Afraid I can't help with PHP.

 

&lt;p&gt;Again, perfectly normal.&lt;/p&gt;&lt;p&gt;From a Mercury perspective there is no problem.&lt;/p&gt;&lt;p&gt;Afraid I can&#039;t help with PHP.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;/p&gt;
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft