// set message as seen $imap->setMessageSeen('inbox', 175, true); // set message as unseen $imap->setMessageSeen('inbox', 175, false); // set message as flagged $imap->setMessageFlagged('inbox', 175, true); // set message as unflagged $imap->setMessageFlagged('inbox', 175, false); // set message as answered $imap->setMessageAnswered('inbox', 175, true); // set message as unanswered $imap->setMessageAnswered('inbox', 175, false); // mark group of messages as seen $imap->setMessageSeen('inbox', 171, true, true); $imap->setMessageSeen('inbox', 172, true, true); $imap->setMessageSeen('inbox', 173, true, true); // and saves it $imap->expunge(); // delete message $imap->deleteMessage('inbox', 174); // mark group of messages as deleted $imap->deleteMessage('inbox', 175, true); $imap->deleteMessage('inbox', 176, true); $imap->deleteMessage('inbox', 177, true); // and delete it $imap->expunge(); // disconnect from server $imap->disconnect(); } catch (Exception $imapEx) { print_r($imapEx); }