POP3::uidl( $msgNum = "" )

In this article

Source

function uidl ($msgNum = "")
{
    //  Returns the UIDL of the msg specified. If called with
    //  no arguments, returns an associative array where each
    //  undeleted msg num is a key, and the msg's uidl is the element
    //  Array element 0 will contain the total number of msgs

    if(!isset($this->FP)) {
        $this->ERROR = "POP3 uidl: " . _("No connection to server");
        return false;
    }

    $fp = $this->FP;
    $buffer = $this->BUFFER;

    if(!empty($msgNum)) {
        $cmd = "UIDL $msgNum";
        $reply = $this->send_cmd($cmd);
        if(!$this->is_ok($reply))
        {
            $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
            return false;
        }
        list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
        return $myUidl;
    } else {
        $this->update_timer();

        $UIDLArray = array();
        $Total = $this->COUNT;
        $UIDLArray[0] = $Total;

        if ($Total < 1)
        {
            return $UIDLArray;
        }
        $cmd = "UIDL";
        fwrite($fp, "UIDL\r\n");
        $reply = fgets($fp, $buffer);
        $reply = $this->strip_clf($reply);
        if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
        if(!$this->is_ok($reply))
        {
            $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
            return false;
        }

        $line = "";
        $count = 1;
        $line = fgets($fp,$buffer);
        while ( !preg_match('/^\.\r\n/',$line)) {
            list ($msg,$msgUidl) = preg_split('/\s+/',$line);
            $msgUidl = $this->strip_clf($msgUidl);
            if($count == $msg) {
                $UIDLArray[$msg] = $msgUidl;
            }
            else
            {
                $UIDLArray[$count] = 'deleted';
            }
            $count++;
            $line = fgets($fp,$buffer);
        }
    }
    return $UIDLArray;
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.