|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42982 FGETS Crash using FSOCKOPEN
Submitted: 2007-10-15 20:49 UTC Modified: 2009-04-21 14:43 UTC
From: mkz at terra dot com dot br Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.4 OS: Windows XP Professional
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mkz at terra dot com dot br
New email:
PHP Version: OS:


 [2007-10-15 20:49 UTC] mkz at terra dot com dot br
Fgets function cause a fatal error in script.

Reproduce code:
class Smtp{
	//Creditos: Red neck adaptada por Micael Vianna (
	var $conn;
	var $user;
	var $pass;
	var $html;
	var $debug = true;
	var $logado = false;
	var $erro;
	function Smtp($host,$porta){
	  $this->conn = fsockopen($host, $porta, $errno, $errstr, 30);
	  $this->Put("EHLO $host");
	function Auth(){
	  $this->Put("AUTH LOGIN");
	function Send($toName, $to, $fromName, $from, $replyTo, $subject, $msg)
	  	// se nao estiver logado, loga
		if (!$this->logado)
			$this->logado = true;
		$this->Put("MAIL FROM: <" . $from.">");
		$this->Put("RCPT TO: <" . $to.">");
		$this->Put($this->toHeader($toName."<".$to.">", $fromName."<".$from.">", $fromName."<".$replyTo.">", $subject));
		$i = 0;
		$dados = $this->conn; 	
	 	return false;
		while (!feof ($dados) || $this->conn) 
		    $buffer = fgets($this->conn, 4096);
	function Put($value){
	  return fputs($this->conn, $value . "\r\n");
	  echo $this->conn;
	function getRetorno($valor)
    	return $valor{0}.$valor{1}.$valor{2};
	function toHeader($to, $from, $replyTo, $subject){
	  $header  = "Message-Id: <". date('YmdHis').".". md5(microtime()).".". strtoupper($from) ."> \r\n";
	  $header .= "From: ". $from . " \r\n";
	  $header .= "To: ".$to." \r\n";
	  $header .= "Reply-To: ".$replyTo."\r\n";
	  $header .= "Subject: ".$subject." \r\n";
	  $header .= "Date: ". date('D, d M Y H:i:s O') ." \r\n";
	  $header .= "Content-Type: text/html; charset=iso-8859-1 \r\n";
	  $header .= "X-MSMail-Priority: High \r\n";
	  return $header;
	function Close(){
	  return fclose($this->conn);
	function getErro()
		return $this->erro;

	$smtp = new Smtp("YOUR SMTP SERVER",25);
	$smtp->debug = false;
	$smtp->user = "YOUR SMTP USERNAME";
	$smtp->pass = "YOUR SMTP PASSWORD";
	if ($smtp->Send('micael','YOUR EMAIL','fulano','YOUR EMAIL','REPLY','Super promo&#65533;&#65533;o',"<html><body><table><tr><td>oi</td><td>tudo</td></tr></table></body></html>"))
		{ echo "ok"; }
		echo "ERRO".$smtp->getErro();


Expected result:
List all status from SMTP connect :)

Actual result:
Fatal error:  Maximum execution time of 10 seconds exceeded line 46


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-16 20:37 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 00:01:31 2024 UTC