sp; case -3:
return("-3 socket could not be created");
case -4:
return("-4 dns lookup on hostname "$hostname" failed");
case -5:
return("-5 connection refused or timed out");
case -6:
return("-6 fdopen() call failed");
case -7:
return("-7 setvbuf() call failed");
default:
return("");
}
}
Function CloseConnection()
{
if($this->connection!=0)
{
fclose($this->connection);
$this->connection=0;
}
}
Function Open()
{
if($this->state!="DISCONNECTED")
return("1 a connection is already opened");
if(($error=$this->OpenConnection())!="")
return($error);
$this->greeting=$this->GetLine();
if(GetType($this->greeting)!="string"
|| strtok($this->greeting," ")!="+OK")
{
$this->CloseConnection();
return("3 POP3 server greeting was not found");
}
$this->greeting=strtok(" ");
$this->must_update=0;
$this->state="AUTHORIZATION";
return("");
}
Function Close()
{
if($this->state=="DISCONNECTED")
return("no connection was opened");
if($this->must_update)
{
if($this->PutLine("QUIT")==0)
return("Could not send the QUIT command");
$response=$this->GetLine();
if(GetType($response)!="string")
return("Could not get quit command response");
if(strtok($response," ")!="+OK")
return("Could not quit the connection: ".strtok(" "));
}
$this->CloseConnection();
$this->state="DISCONNECTED";
return("");
}
Function Login($user,$password,$apop)
{
if($this->state!="AUTHORIZATION")
return("connection is not in AUTHORIZATION state");
if($apop)
{
if($this->PutLine("APOP $user ".md5($this->greeting.$password))==0)
return("Could not send the APOP command");
$response=$this->GetLine();
&nbs
return("-3 socket could not be created");
case -4:
return("-4 dns lookup on hostname "$hostname" failed");
case -5:
return("-5 connection refused or timed out");
case -6:
return("-6 fdopen() call failed");
case -7:
return("-7 setvbuf() call failed");
default:
return("");
}
}
Function CloseConnection()
{
if($this->connection!=0)
{
fclose($this->connection);
$this->connection=0;
}
}
Function Open()
{
if($this->state!="DISCONNECTED")
return("1 a connection is already opened");
if(($error=$this->OpenConnection())!="")
return($error);
$this->greeting=$this->GetLine();
if(GetType($this->greeting)!="string"
|| strtok($this->greeting," ")!="+OK")
{
$this->CloseConnection();
return("3 POP3 server greeting was not found");
}
$this->greeting=strtok(" ");
$this->must_update=0;
$this->state="AUTHORIZATION";
return("");
}
Function Close()
{
if($this->state=="DISCONNECTED")
return("no connection was opened");
if($this->must_update)
{
if($this->PutLine("QUIT")==0)
return("Could not send the QUIT command");
$response=$this->GetLine();
if(GetType($response)!="string")
return("Could not get quit command response");
if(strtok($response," ")!="+OK")
return("Could not quit the connection: ".strtok(" "));
}
$this->CloseConnection();
$this->state="DISCONNECTED";
return("");
}
Function Login($user,$password,$apop)
{
if($this->state!="AUTHORIZATION")
return("connection is not in AUTHORIZATION state");
if($apop)
{
if($this->PutLine("APOP $user ".md5($this->greeting.$password))==0)
return("Could not send the APOP command");
$response=$this->GetLine();
&nbs