PHP Classes

reached the end of data error

Recommend this page to a friend!

      SMTP E-mail sending class  >  All threads  >  reached the end of data error  >  (Un) Subscribe thread alerts  
Subject:reached the end of data error
Summary:Strange error
Messages:9
Author:ck miller
Date:2009-09-30 17:32:19
Update:2009-11-23 20:55:42
 

  1. reached the end of data error   Reply   Report abuse  
Picture of ck miller ck miller - 2009-09-30 17:32:19
I just received an error while trying to send an email:
"reached the end of data while reading from the SMTP server conection"

It has worked before. PHP 5.2.11
Anyone?

Thanks
cappac

  2. Re: reached the end of data error   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-09-30 19:16:50 - In reply to message 1 from ck miller
This means that the server disconnected while the class was trying to read the server response.

It is hard to tell what happened. Maybe if you set the debug variable and show the class output that is displayed I can figure what happened.

  3. Re: reached the end of data error   Reply   Report abuse  
Picture of ck miller ck miller - 2009-10-02 10:38:00 - In reply to message 2 from Manuel Lemos
Here's the log:

Resolving SMTP server domain "localhost"...
Connecting to host address "127.0.0.1" port 25...
Connected to SMTP server "localhost".
Cound not send the message to backup@xxx.com. Error: reached the end of data while reading from the SMTP server conection

  4. Re: reached the end of data error   Reply   Report abuse  
Picture of ck miller ck miller - 2009-10-02 15:48:05 - In reply to message 3 from ck miller
After endless testing I found that we have a BUG in PHP 5.2.11:

bugs.php.net/bug.php?id=49706&edit= ...

The code aborts due to the feof query:
if(feof($this->connection))
{
$this->error="reached the end of data while reading from the SMTP server conection";
return("");
}

  5. Re: reached the end of data error   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-10-02 17:43:28 - In reply to message 3 from ck miller
It seems the connection is ended before the data arrives from the server. Try changing the timeout values to 0 or an high value.

  6. Re: reached the end of data error   Reply   Report abuse  
Picture of ck miller ck miller - 2009-10-03 16:04:24 - In reply to message 5 from Manuel Lemos
Yep, that's what I thought first.
But I soon noticed that it had to be something else.

Then I conducted a quick test with:
$fp=fsockopen('localhost',25,...); if ($fp) echo fgets(...);
Working.

As soon as I put the fgets in a while(!feof($fp)) loop I faced the problem again.

Conclusion: feof is sometimes true and sometimes false.

I got rid of the problem by commenting the if(feof($this->connection)) in your GetLine() function as a temporary solution.

  7. Re: reached the end of data error   Reply   Report abuse  
Picture of Thomas Brunnthaler Thomas Brunnthaler - 2009-10-07 12:37:17 - In reply to message 6 from ck miller
Thanks cappac for the PHP FEOF BUG FINDING.

  8. Re: reached the end of data error   Reply   Report abuse  
Picture of Serge Kossouho Serge Kossouho - 2009-11-23 15:50:20 - In reply to message 7 from Thomas Brunnthaler
Hi
I have the same problem and should we say that we can solve this problem by upgrading the php version on Windows XP and Server 2008. If so, please advise for the version to upgrade to.

Regards

  9. Re: reached the end of data error   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-11-23 20:55:42 - In reply to message 8 from Serge Kossouho
The bug report says it is fixed in PHP 5.2.12 or later. So the upgrade may work.