145 $this->connected =
false;
164 if (
$port ==
false) {
171 if (
$tval ==
false) {
177 $this->do_debug = $debug_level;
185 $result = $this->
Connect($this->host, $this->port, $this->tval);
188 $login_result = $this->
Login($this->username, $this->password);
214 if ($this->connected) {
223 set_error_handler(array(&$this,
'catchWarning'));
226 $this->pop_conn = fsockopen(
$host,
233 restore_error_handler();
236 if ($this->error && $this->do_debug >= 1) {
241 if ($this->pop_conn ==
false) {
243 $this->error = array(
244 'error' =>
"Failed to connect to server $host on port $port",
249 if ($this->do_debug >= 1) {
259 if (version_compare(phpversion(),
'5.0.0',
'ge')) {
260 stream_set_timeout($this->pop_conn,
$tval, 0);
263 if (substr(PHP_OS, 0, 3) !==
'WIN') {
264 socket_set_timeout($this->pop_conn,
$tval, 0);
274 $this->connected =
true;
288 if ($this->connected ==
false) {
289 $this->error =
'Not connected to POP3 server';
291 if ($this->do_debug >= 1) {
330 fclose($this->pop_conn);
345 $pop3_response = fgets($this->pop_conn, $size);
347 return $pop3_response;
357 $bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
369 if (substr($string, 0, 3) !==
'+OK') {
370 $this->error = array(
371 'error' =>
"Server reported an error: $string",
376 if ($this->do_debug >= 1) {
394 foreach ($this->error as $single_error) {
395 print_r($single_error);
410 $this->error[] = array(
411 'error' =>
"Connecting to the POP3 server raised a PHP warning: ",