135 $this->connected =
false;
152 if (
$port ==
false) {
159 if (
$tval ==
false) {
165 $this->do_debug = $debug_level;
176 $login_result = $this->
Login($this->username, $this->password);
202 if ($this->connected) {
211 set_error_handler(array(&$this,
'catchWarning'));
214 $this->pop_conn = fsockopen(
$host,
221 restore_error_handler();
224 if ($this->error && $this->do_debug >= 1) {
229 if ($this->pop_conn ==
false) {
231 $this->error = array(
232 'error' =>
"Failed to connect to server $host on port $port",
237 if ($this->do_debug >= 1) {
247 if (version_compare(phpversion(),
'5.0.0',
'ge')) {
248 stream_set_timeout($this->pop_conn,
$tval, 0);
251 if (substr(PHP_OS, 0, 3) !==
'WIN') {
252 socket_set_timeout($this->pop_conn,
$tval, 0);
262 $this->connected =
true;
276 if ($this->connected ==
false) {
277 $this->error =
'Not connected to POP3 server';
279 if ($this->do_debug >= 1) {
321 fclose($this->pop_conn);
336 $pop3_response = fgets($this->pop_conn, $size);
338 return $pop3_response;
348 $bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
360 if (substr($string, 0, 3) !==
'+OK') {
361 $this->error = array(
362 'error' =>
"Server reported an error: $string",
367 if ($this->do_debug >= 1) {
385 foreach ($this->error as $single_error) {
386 print_r($single_error);
401 $this->error[] = array(
402 'error' =>
"Connecting to the POP3 server raised a PHP warning: ",