public function tidy_old_messages() {
        // Grab the new IMAP client.
        if (!$this->get_imap_client()) {
            return false;
        }

        // Open the mailbox.
        mtrace("Searching for messages older than 24 hours in the '" .
                $this->get_confirmation_folder() . "' folder.");
        $this->client->openMailbox($this->get_confirmation_folder());

        $mailbox = $this->get_mailbox();

        // Build the search.
        $search = new \Horde_Imap_Client_Search_Query();

        // Delete messages older than 24 hours old.
        $search->intervalSearch(DAYSECS, \Horde_Imap_Client_Search_Query::INTERVAL_OLDER);

        $results = $this->client->search($mailbox, $search);

        // Build the base query.
        $query = new \Horde_Imap_Client_Fetch_Query();
        $query->envelope();

        // Retrieve the messages and mark them for removal.
        $messages = $this->client->fetch($mailbox, $query, array('ids' => $results['match']));
        mtrace("Found " . $messages->count() . " messages for removal.");
        foreach ($messages as $message) {
            $this->add_flag_to_message($message->getUid(), self::MESSAGE_DELETED);
        }

        mtrace("Finished removing messages.");
        $this->close_connection();

        return true;
    }