/**
  * Sets read or unread the selected messages
  *
  * @param MailAccount $account   
  * @param mixed   $uid    UID's of messages can be an array or a number
  * @param boolean  $read   if true mark as unread else mark as read
  * 
  * @return 
  *
  */
 static function setReadUnreadImapMails(MailAccount $account, $folder, $uid, $read = true)
 {
     if ($account->getIncomingSsl()) {
         $imap = new Net_IMAP($ret, "ssl://" . $account->getServer(), $account->getIncomingSslPort());
     } else {
         $imap = new Net_IMAP($ret, "tcp://" . $account->getServer());
     }
     if (PEAR::isError($ret)) {
         throw new Exception($ret->getMessage());
     }
     //login
     $login_ret = $imap->login($account->getEmail(), self::ENCRYPT_DECRYPT($account->getPassword()), null, false);
     if (PEAR::isError($login_ret)) {
         throw new Exception($login_ret->getMessage());
     }
     //select folder
     $folder_ret = $imap->selectMailbox($folder);
     if (PEAR::isError($folder_ret)) {
         throw new Exception($folder_ret->getMessage());
     }
     //get msgs ids by uids
     $ret = $imap->getMessagesListUid($uid);
     if (!empty($ret)) {
         $msg_id = array();
         foreach ($ret as $msg) {
             $msg_id[] = $msg['msg_id'];
         }
         //mark as read or unread by msg id
         if ($read) {
             //mark as read
             $imap->addSeen($msg_id);
         } else {
             //mark as unread
             $imap->removeSeen($msg_id);
         }
     }
     //disconnect
     $imap->disconnect();
 }