public function saveGmailDetails($parameters)
 {
     $username = $parameters["gmailusername"];
     $password = $parameters["gmailpassword"];
     $userid = $_SESSION["userid"];
     try {
         $inbox = $this->getImapConnection($username, $password, "INBOX");
     } catch (Exception $e) {
         error_log("Errror Caugt!!!");
         return self::$responder->constructErrorResponse("I could not connect to Gmail. Make sure your login details are correct.");
     }
     try {
         self::$gmailDAO->saveGmailDetails($userid, $username, $password);
     } catch (Exception $e) {
     }
     $folderList = array();
     $emailFolderList = imap_getmailboxes($inbox, self::INBOX, "*");
     error_log("list size: " . sizeof($emailFolderList));
     if (is_array($emailFolderList)) {
         $count = 0;
         foreach ($emailFolderList as $key => $val) {
             $temp = imap_utf7_decode($val->name);
             $folder = str_replace(self::INBOX, "", $temp);
             if (!strstr($folder, "[Gmail]")) {
                 $folderList["folder" . ++$count] = $folder;
             }
         }
     } else {
         return self::$responder->constructErrorResponse("Could not get the list of folder from your account, please try again.");
     }
     imap_close($inbox);
     return self::$responder->constructResponseForKeyValue(array_reverse($folderList));
 }
Exemple #2
0
 function listMailboxes()
 {
     $mailboxes = imap_list($this->stream, $this->target, "*");
     foreach ($mailboxes as &$folder) {
         $folder = str_replace($this->target, "", imap_utf7_decode($folder));
     }
     return $mailboxes;
 }
Exemple #3
0
 public function getListingFolders()
 {
     $folders = imap_list($this->Stream, $this->_connectionString, "*");
     foreach ($folders as $key => $folder) {
         $folder = str_replace($this->_connectionString, "", imap_utf7_decode($folder));
         $folders[$key] = $folder;
     }
     return $folders;
 }
Exemple #4
0
 public function getFoldersList()
 {
     $out = [];
     $list = imap_list($this->imapStream, $this->getMailbox(), '*');
     if (is_array($list)) {
         foreach ($list as $val) {
             $out[] = imap_utf7_decode($val);
         }
     } else {
         throw new \Exception('Imap list failed: ' . imap_last_error());
     }
     return $out;
 }
Exemple #5
0
 /**
  * Vrati pole vsetkych najdenych mailboxov na emailovom konte
  *
  * @return array
  * @throws Exception
  */
 public function getFolders()
 {
     $mbox = $this->openMailServerConnection();
     $result = array();
     $boxes = imap_getmailboxes($mbox, '{' . IMAP_HOST . '}', '*');
     if (is_array($boxes)) {
         foreach ($boxes as $key => $val) {
             $result[$key]['name'] = str_replace('{' . IMAP_HOST . '}', '', imap_utf7_decode($val->name));
             $result[$key]['delimiter'] = $val->delimiter;
             $result[$key]['attribs'] = $val->attributes;
             $Status = imap_status($mbox, $val->name, SA_ALL);
             $result[$key]['msgNum'] = $Status->messages;
             $result[$key]['newNum'] = isset($Status->recent) ? $Status->recent : 0;
             $result[$key]['unreadNum'] = isset($Status->unseen) ? $Status->unseen : 0;
         }
     } else {
         Logger::error("imap_getmailboxes() failed: " . imap_last_error());
     }
     //        imap_close($mbox);
     return $result;
 }
Exemple #6
0
 function getLabels()
 {
     $this->load->database();
     $this->load->model('grabber');
     $inbox = $this->getConnect('INBOX');
     $folders = imap_list($inbox, "{imap.gmail.com:993/imap/ssl}", "*");
     $i = 0;
     $folde = array();
     foreach ($folders as $folder) {
         $fold = str_replace("{imap.gmail.com:993/imap/ssl}", " ", imap_utf7_decode($folder));
         if ($this->grabber->check_label_exist(htmlentities($fold)) == 0) {
             $folde[$i]['id'] = uniqid();
             $folde[$i]['name'] = htmlentities($fold);
             $i++;
         }
     }
     if (count($folde) > 0) {
         $this->grabber->insert_labels($folde);
     }
     //imap_close($inbox);
 }
 /**
  * Function to delete messages in a mailbox, based on date
  * NOTE: this is global ... will affect all mailboxes except any that have 'sent' in the mailbox name
  */
 public function globalDelete()
 {
     $dateArr = split('-', $this->deleteMsgDate);
     // date format is yyyy-mm-dd
     $delDate = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]);
     $port = $this->port . '/' . $this->service . '/' . $this->serviceOption;
     $mboxt = imap_open('{' . $this->mailhost . ":" . $port . '}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
     $list = imap_getmailboxes($mboxt, '{' . $this->mailhost . ":" . $port . '}', "*");
     $mailboxFound = false;
     if (is_array($list)) {
         foreach ($list as $key => $val) {
             // get the mailbox name only
             $nameArr = split('}', imap_utf7_decode($val->name));
             $nameRaw = $nameArr[count($nameArr) - 1];
             if (!stristr($nameRaw, 'sent')) {
                 $mboxd = imap_open('{' . $this->mailhost . ":" . $port . '}' . $nameRaw, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE);
                 $messages = imap_sort($mboxd, SORTDATE, 0);
                 $i = 0;
                 $check = imap_mailboxmsginfo($mboxd);
                 foreach ($messages as $message) {
                     $header = imap_header($mboxd, $message);
                     $fdate = date("F j, Y", $header->udate);
                     // purge if prior to global delete date
                     if ($header->udate < $delDate) {
                         imap_delete($mboxd, $message);
                     }
                     $i++;
                 }
                 imap_expunge($mboxd);
                 imap_close($mboxd);
             }
         }
     }
 }
 private function decodePart($part)
 {
     $bodyStructure = imap_bodystruct($this->imap_stream, $this->message_index, $part);
     $att_data = imap_fetchbody($this->imap_stream, $this->message_index, $part);
     switch ($bodyStructure->encoding) {
         case '1':
             //utf7 //php lies, this is 0
             $filedata = @imap_utf7_decode($att_data);
             break;
             //			case '1': //utf8 //php lies, this is utf7
             //				$filedata = imap_utf8($att_data);
             //				break;
         //			case '1': //utf8 //php lies, this is utf7
         //				$filedata = imap_utf8($att_data);
         //				break;
         case '3':
             //base64
             $filedata = imap_base64($att_data);
             break;
         case '4':
             //quoted printable
             $filedata = imap_qprint($att_data);
             break;
         default:
             $filedata = $att_data;
     }
     return $filedata;
 }
Exemple #9
0
function get_folder_caption($realname)
{
    $spaces = 0;
    $last = $realname;
    if (strpos($realname, ".") !== false) {
        $last = substr($realname, strrpos($realname, ".") + 1);
        $spaces = substr_count($realname, ".");
    }
    return str_repeat("&nbsp;&nbsp;", $spaces) . imap_utf7_decode($last);
}
Exemple #10
0
         printf('<input type="hidden" name="lists[%d]" value="%s">', $key, $val);
     }
 }
 foreach (array("server", "user", "password", "markhtml", "overwrite", "onlyfull", "notify", "nameattributes", "attributeone", "attributetwo") as $item) {
     printf('<input type="hidden" name="%s" value="%s">', $item, $_POST[$item]);
 }
 $done = 0;
 $level = 0;
 $foldersdone = array();
 $tree = array();
 while (sizeof($folderdone) < sizeof($folders) && $level < 10) {
     reset($folders);
     asort($folders);
     while (list($key, $val) = each($folders)) {
         $delim = $val->delimiter;
         $name = str_replace("{" . $server . "}INBOX", "", imap_utf7_decode($val->name));
         $parent = mailBoxParent($name, $delim, $level);
         $folder = mailBoxName($name, $delim, $level);
         if ($folder) {
             if (!is_array($tree[$parent])) {
                 $tree[$parent] = array("node" => $parent, "children" => array());
             }
             if (!in_array($folder, $tree[$parent]["children"])) {
                 array_push($tree[$parent]["children"], $folder);
             }
             #   print $parent . " ".$folder."<br/>";
             flush();
         } else {
             array_push($foldersdone, $name);
         }
     }
Exemple #11
0
 /**
  * Function to check if a mailbox exists
  * - if not found, it will create it
  * @param string  $mailbox        (the mailbox name, must be in 'INBOX.checkmailbox' format)
  * @param boolean $create         (whether or not to create the checkmailbox if not found, defaults to true)
  * @return boolean
  */
 function isMailboxExist($mailbox)
 {
     if (trim($mailbox) == '' || !strstr($mailbox, 'INBOX.')) {
         // this is a critical error with either the mailbox name blank or an invalid mailbox name
         // need to stop processing and exit at this point
         //echo "Invalid mailbox name for move operation. Cannot continue.<br />\n";
         //echo "TIP: the mailbox you want to move the message to must include 'INBOX.' at the start.<br />\n";
         return false;
     }
     $port = $this->port . '/' . $this->service . ($this->service_option != 'none' ? '/' . $this->service_option : '');
     $mbox = imap_open('{' . $this->mailhost . ":" . $port . '}', $this->mailbox_username, $this->mailbox_password, OP_HALFOPEN);
     $list = imap_getmailboxes($mbox, '{' . $this->mailhost . ":" . $port . '}', "*");
     $mailboxFound = false;
     if (is_array($list)) {
         foreach ($list as $key => $val) {
             // get the mailbox name only
             $nameArr = split('}', imap_utf7_decode($val->name));
             $nameRaw = $nameArr[count($nameArr) - 1];
             if ($mailbox == $nameRaw) {
                 $mailboxFound = true;
             }
         }
         //      if ( ($mailboxFound === false) && $create ) {
         //        @imap_createmailbox($mbox, imap_utf7_encode('{'.$this->mailhost.":".$port.'}' . $mailbox));
         //        imap_close($mbox);
         //        return true;
         //      } else {
         //        imap_close($mbox);
         //        return false;
         //      }
     } else {
         imap_close($mbox);
         return false;
     }
 }
Exemple #12
0
         printf('<input type="hidden" name="lists[%d]" value="%s">', $key, $val);
     }
 }
 foreach (array('server', 'user', 'password', 'markhtml', 'overwrite', 'onlyfull', 'notify', 'nameattributes', 'attributeone', 'attributetwo') as $item) {
     printf('<input type="hidden" name="%s" value="%s">', $item, $_POST[$item]);
 }
 $done = 0;
 $level = 0;
 $foldersdone = array();
 $tree = array();
 while (count($folderdone) < count($folders) && $level < 10) {
     reset($folders);
     asort($folders);
     while (list($key, $val) = each($folders)) {
         $delim = $val->delimiter;
         $name = str_replace('{' . $server . '}INBOX', '', imap_utf7_decode($val->name));
         $parent = mailBoxParent($name, $delim, $level);
         $folder = mailBoxName($name, $delim, $level);
         if ($folder) {
             if (!is_array($tree[$parent])) {
                 $tree[$parent] = array('node' => $parent, 'children' => array());
             }
             if (!in_array($folder, $tree[$parent]['children'])) {
                 array_push($tree[$parent]['children'], $folder);
             }
             #   print $parent . " ".$folder."<br/>";
             flush();
         } else {
             array_push($foldersdone, $name);
         }
     }
 static function convert_encoding($string, $to, $from = '')
 {
     // Convert string to ISO_8859-1
     if ($from == "UTF-8") {
         $iso_string = utf8_decode($string);
     } else {
         if ($from == "UTF7-IMAP") {
             $iso_string = imap_utf7_decode($string);
         } else {
             $iso_string = $string;
         }
     }
     // Convert ISO_8859-1 string to result coding
     if ($to == "UTF-8") {
         return utf8_encode($iso_string);
     } else {
         if ($to == "UTF7-IMAP") {
             return imap_utf7_encode($iso_string);
         } else {
             return $iso_string;
         }
     }
 }
Exemple #14
0
 function GetFolder($id)
 {
     $folder = new SyncFolder();
     $folder->serverid = $id;
     // explode hierarchy
     $fhir = explode(".", $id);
     // compare on lowercase strings
     $lid = strtolower($id);
     if ($lid == "inbox") {
         $folder->parentid = "0";
         // Root
         $folder->displayname = "Inbox";
         $folder->type = SYNC_FOLDER_TYPE_INBOX;
     } else {
         if ($lid == "drafts") {
             $folder->parentid = "0";
             $folder->displayname = "Drafts";
             $folder->type = SYNC_FOLDER_TYPE_DRAFTS;
         } else {
             if ($lid == "trash") {
                 $folder->parentid = "0";
                 $folder->displayname = "Trash";
                 $folder->type = SYNC_FOLDER_TYPE_WASTEBASKET;
                 $this->_wasteID = $id;
             } else {
                 if ($lid == "sent" || $lid == "sent items" || $lid == IMAP_SENTFOLDER) {
                     $folder->parentid = "0";
                     $folder->displayname = "Sent";
                     $folder->type = SYNC_FOLDER_TYPE_SENTMAIL;
                     $this->_sentID = $id;
                 } else {
                     if ($lid == "inbox.drafts") {
                         $folder->parentid = $fhir[0];
                         $folder->displayname = "Drafts";
                         $folder->type = SYNC_FOLDER_TYPE_DRAFTS;
                     } else {
                         if ($lid == "inbox.trash") {
                             $folder->parentid = $fhir[0];
                             $folder->displayname = "Trash";
                             $folder->type = SYNC_FOLDER_TYPE_WASTEBASKET;
                             $this->_wasteID = $id;
                         } else {
                             if ($lid == "inbox.sent") {
                                 $folder->parentid = $fhir[0];
                                 $folder->displayname = "Sent";
                                 $folder->type = SYNC_FOLDER_TYPE_SENTMAIL;
                                 $this->_sentID = $id;
                             } else {
                                 if (count($fhir) > 1) {
                                     $folder->displayname = windows1252_to_utf8(imap_utf7_decode(array_pop($fhir)));
                                     $folder->parentid = implode(".", $fhir);
                                 } else {
                                     $folder->displayname = windows1252_to_utf8(imap_utf7_decode($id));
                                     $folder->parentid = "0";
                                 }
                                 $folder->type = SYNC_FOLDER_TYPE_OTHER;
                             }
                         }
                     }
                 }
             }
         }
     }
     //advanced debugging
     //debugLog("IMAP-GetFolder(id: '$id') -> " . print_r($folder, 1));
     return $folder;
 }
 function utf7_decode_string($data_str)
 {
     $name = array();
     $name['folder_before'] = '';
     $name['folder_after'] = '';
     $name['translated'] = '';
     if (strstr($data_str, '}')) {
         // folder name at this stage is  {SERVER_NAME:PORT}FOLDERNAME
         // get everything to the right of the bracket "}", INCLUDES the bracket itself
         $name['folder_before'] = strstr($data_str, '}');
         // get rid of that 'needle' "}"
         $name['folder_before'] = substr($name['folder_before'], 1);
         // translate
         if (function_exists('recode_string') == False) {
             $name['folder_after'] = imap_utf7_decode($name['folder_before']);
         } else {
             // Modif UTF-8 by Sam Przyswa so now compatible with MS-Outlook and Netscape accentued folder name
             $name_tmp = str_replace("&", "+", $name['folder_before']);
             $name['folder_after'] = recode_string("UTF-7..ISO-8859-1", $name_tmp);
         }
         // "imap_utf7_decode" returns False if no translation occured (supposed to, can return identical string too)
         if ($name['folder_after'] == False || $name['folder_before'] == $name['folder_after']) {
             // no translation occured
             if ($this->debug_utf7 > 0) {
                 echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning unmodified name, NO decoding needed, returning feed $data_str: [' . htmlspecialchars(serialize($data_str)) . ']<br>';
             }
             return $data_str;
         } else {
             // replace old folder name with new folder name
             $name['translated'] = str_replace($name['folder_before'], $name['folder_after'], $data_str);
             if ($this->debug_utf7 > 0) {
                 echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning decoded name, $name[] DUMP: [' . htmlspecialchars(serialize($name)) . ']<br>';
             }
             return $name['translated'];
         }
     } else {
         // folder name at this stage is  FOLDERNAME
         // there is NO {SERVER} part in this name,
         // DOES THIS EVER HAPPEN comming *from* the server? I DO NOT THINK SO, but just in case
         // translate
         $name['translated'] = imap_utf7_decode($data_str);
         // "imap_utf7_decode" returns False if no translation occured
         if ($name['translated'] == False || $name['folder_before'] == $data_str) {
             // no translation occured
             if ($this->debug_utf7 > 0) {
                 echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning unmodified name, NO decoding needed, returning feed $data_str: [' . htmlspecialchars(serialize($data_str)) . ']<br>';
             }
             return $data_str;
         } else {
             if ($this->debug_utf7 > 0) {
                 echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning decoded name, $name[] DUMP: [' . htmlspecialchars(serialize($name)) . ']<br>';
             }
             return $name['translated'];
         }
     }
 }
 function decodeFolderName($_folderName)
 {
     if ($this->mbAvailable) {
         return mb_convert_encoding($_folderName, $this->displayCharset, "UTF7-IMAP");
     }
     // if not
     return @imap_utf7_decode($_folderName);
 }
	/**
	 * Constroi a baixa de correio
	 * @param	Imap $imap
	 * @param	string $fullname
	 * @param	string $ref
	 */
	public function __construct( Imap $imap , $fullname , $ref ) {
		$this->fullname = $fullname;
		$this->imap = $imap;
		$this->name = mb_convert_encoding( imap_utf7_decode( str_replace( $ref , null , $fullname ) ) , 'UTF-8' );

	}
 /**
  * decode foldername given by IMAP server (convert from UTF7-IMAP to UTF8)
  * 
  * @param string $_folderName
  * @return string
  */
 public static function decodeFolderName($_folderName)
 {
     if (extension_loaded('mbstring')) {
         $result = mb_convert_encoding($_folderName, "utf-8", "UTF7-IMAP");
     } else {
         if (extension_loaded('imap')) {
             $result = iconv('ISO-8859-1', 'utf-8', imap_utf7_decode($_folderName));
         } else {
             // fallback
             $result = Tinebase_Helper::replaceSpecialChars($_folderName);
         }
     }
     return $result;
 }
Exemple #19
0
 public function pub_getAccountFolders($o)
 {
     $this->setAccount($o['account']);
     $res = array('text' => $o['account'], 'uiProvider' => 'col', 'expanded' => true, 'allowDrop' => true, 'allowChildren' => true, 'folderType' => 'account');
     $this->imapProxy->open();
     if (!$this->imapProxy->isConnected()) {
         return $res;
     }
     $list = $this->imapProxy->getmailboxes("*");
     if (is_array($list)) {
         foreach ($list as $val) {
             $name = utf8_encode(imap_utf7_decode(str_replace($this->imapProxy->getAccountVar('cnx'), '', $val->name)));
             if (trim($name) != '') {
                 $tmpArr = explode($val->delimiter, $name);
                 $tmp =& $res;
                 foreach ($tmpArr as $k => $v) {
                     $id = implode($val->delimiter, array_slice($tmpArr, 0, $k + 1));
                     if (!array_key_exists('children', $tmp)) {
                         $tmp['children'] = array();
                     }
                     $subId = $id;
                     if (!array_key_exists($subId, $tmp['children'])) {
                         //db($subId);
                         //db($this->imapProxy->getacl($subId));
                         $tmp['children'][$subId] = array('text' => $v, 'id' => base64_encode($id), 'fid' => $id, 'uiProvider' => 'col', 'cls' => ' x-tree-node-collapsed x-tree-node-icon ', 'nb' => 0, 'allowDrop' => true, 'stat' => $this->imapProxy->status($subId), 'folderType' => 'folder');
                         QDImap::personalizeFolderIcon($tmp['children'][$subId], strtolower($v));
                     }
                     $tmp =& $tmp['children'][$subId];
                 }
             }
         }
         uasort($res['children'], array('QDImap', 'sortNaturalMailFolders'));
     } else {
         echo "imap_getmailboxes failed : " . imap_last_error() . "\n";
     }
     $this->flatAssocChildren($res);
     return array($res);
 }
 /**
  * Wrapper for imap_utf7_encode().
  * @param string $mailbox
  * @return string
  */
 public function utf7Decode($mailbox)
 {
     return imap_utf7_decode($mailbox);
 }
Exemple #21
0
 /**
  * Get mailbox names
  * 
  * @return array
  */
 private function getMailboxNames()
 {
     if (null === $this->mailboxNames) {
         $mailboxes = imap_getmailboxes($this->resource, $this->server, '*');
         foreach ($mailboxes as $mailbox) {
             $this->mailboxNames[] = imap_utf7_decode(str_replace($this->server, '', $mailbox->name));
         }
     }
     return $this->mailboxNames;
 }
Exemple #22
0
 private function folderDisplayName($folder)
 {
     $f = explode("/", $folder);
     if (substr($f[0], 0, 6) == "shared") {
         // shared folder in UPPER
         $s = explode(".", $folder);
         return strtoupper(windows1252_to_utf8(imap_utf7_decode($s[1])));
     }
     if ($f[0] == "INBOX") {
         $type = $this->readFolderAnnotation($folder);
         if ($type == "contact.default" || $type == "event.default" || $type == "task.default") {
             //default folder all min lowaercase
             $r = windows1252_to_utf8(imap_utf7_decode($f[1]));
             return strtolower(windows1252_to_utf8(imap_utf7_decode(array_pop($f))));
         } else {
             //others    AA problem when we have sub sub folder
             //must keep the last one
             return ucfirst(windows1252_to_utf8(imap_utf7_decode(array_pop($f))));
         }
     }
     if ($f[0] == "user") {
         $type = $this->readFolderAnnotation($folder);
         $t = explode(".", $type);
         //find the user
         $fname = array_pop($f);
         $r = windows1252_to_utf8(imap_utf7_decode($fname . "(" . $f[1] . ")"));
         return windows1252_to_utf8($r);
     }
 }
Exemple #23
0
 /**
  * mailboxes_list()
  *   get a list of the mailboxes avaible on the server
  */
 function mailboxes_list()
 {
     if ($this->connection == 0) {
         return false;
     }
     $boxes = array();
     $list = imap_list($this->connection, "\\{{$this->server}:{$this->port}}", "*");
     if (is_array($list)) {
         reset($list);
         while (list($key, $val) = each($list)) {
             $boxes[] = substr(strstr(imap_utf7_decode($val), '}'), 1);
         }
     } else {
         if ($this->debug) {
             echo "Had problems collecting mailboxes list..";
             echo implode("<br />\n", imap_errors());
         }
         return false;
     }
     return $boxes;
 }
Exemple #24
0
 function GetWasteBasket()
 {
     if ($this->_wasteID == false) {
         //try to get the waste basket without doing complete hierarchy sync
         $wastebaskt = @imap_getmailboxes($this->_mbox, $this->_server, "Trash");
         if (isset($wastebaskt[0])) {
             $this->_wasteID = imap_utf7_decode(substr($wastebaskt[0]->name, strlen($this->_server)));
             return $this->_wasteID;
         }
         //try get waste id from hierarchy if it wasn't possible with above for some reason
         $this->GetHierarchy();
     }
     return $this->_wasteID;
 }
 function getMailboxes()
 {
     if (!($folders = imap_list($this->mbox, $this->srvstr, "*")) || !is_array($folders)) {
         return null;
     }
     $list = array();
     foreach ($folders as $folder) {
         $list[] = str_replace($this->srvstr, '', imap_utf7_decode(trim($folder)));
     }
     return $list;
 }
Exemple #26
0
                 foreach ($p->parameters as $param) {
                     if (strtoupper($param->attribute) == 'NAME' || strtoupper($param->attribute) == 'FILENAME') {
                         $selectBoxDisplay[$k] = $param->value;
                     }
                 }
             }
         }
     }
     if ($p->encoding == 3) {
         $selectBoxDisplay[$k] = imap_base64($selectBoxDisplay[$k]);
     }
     if ($p->encoding == 4) {
         $selectBoxDisplay[$k] = imap_qprint($selectBoxDisplay[$k]);
     }
 }
 $sentcheck = imap_utf7_decode($imapfolder);
 $sentcheck = preg_replace("/{(.*)}INBOX/", "", $sentcheck);
 $sentcheck = preg_replace("/\\//", "", $sentcheck, 1);
 if ($sentcheck == "Sent") {
     $subj = $headrs->to;
 } else {
     $subj = $headrs->from;
 }
 $replstr = "";
 if ($headrs->answered && !$headrs->seen) {
     $replstr = " url(./iui/dot.png), url(./iui/repl.png); ";
 }
 if ($headrs->answered && $headrs->seen) {
     $replstr = "url(./iui/repl.png); ";
 }
 if (!$headrs->answered && !$headrs->seen) {
 /**
  * Gets listing the folders
  *
  * This function returns an object containing listing the folders.
  * The object has the following properties: messages, recent, unseen, uidnext, and uidvalidity.
  *
  * @return array listing the folders
  */
 public function getListingFolders()
 {
     $folders = imap_list($this->getImapStream(), $this->imapPath, "*");
     foreach ($folders as $key => $folder) {
         $folder = str_replace($this->imapPath, "", imap_utf7_decode($folder));
         $folders[$key] = $folder;
     }
     return $folders;
 }
<?php

// $server = "{imap.example.org:993/ssl/novalidate-cert}";
// $username = "******";
// $password = "******";
$mbox = imap_open($server, $username, $password, OP_HALFOPEN) or die("unable to connect: " . imap_last_error());
$list = imap_getmailboxes($mbox, $server, "*");
if (is_array($list)) {
    foreach ($list as $val) {
        echo imap_utf7_decode($val->name) . "\n";
    }
} else {
    echo "imap_list failed: " . imap_last_error() . "\n";
}
imap_close($mbox);
Exemple #29
0
die("protected");
//mysql_query("TRUNCATE TABLE winamp_emails");
//mysql_query("TRUNCATE TABLE winamp_email_bodies");
$mailboxRoot = '{64.15.252.17:143}';
$mailUsername = '******';
$mailPassword = '******';
// get mailboxes
$imap = imap_open($mailboxRoot, $mailUsername, $mailPassword, OP_HALFOPEN) or die("Can't connect: " . imap_last_error());
$mailboxes = imap_getmailboxes($imap, "{64.15.252.17:143}", "*");
imap_close($imap);
$total_added = 0;
$total_time = 0;
//go through each mailbox
if (is_array($mailboxes)) {
    foreach ($mailboxes as $key => $val) {
        $thisBox = imap_utf7_decode($val->name);
        $boxName = substr($thisBox, strlen($mailboxRoot));
        if ($boxName == "Inbox") {
            $startTime = time();
            $imap = imap_open($mailboxRoot . $boxName, $mailUsername, $mailPassword) or die("Can't open {$boxName} box! " . imap_last_error());
            $added = 0;
            $num_msg = imap_num_msg($imap);
            //if ($num_msg > 40) $num_msg = 40;
            // go through each message
            for ($i = 1; $i <= $num_msg; $i++) {
                $thisUID = imap_uid($imap, $i);
                $result = mysql_query("SELECT * FROM winamp_emails WHERE uid = '{$thisUID}'");
                if (mysql_num_rows($result) == 0) {
                    $header = imap_headerinfo($imap, $i);
                    $thisTo = addslashes($header->toaddress);
                    $thisCC = addslashes($header->ccaddress);
Exemple #30
0
 /**
  * Wrapper method for imap_list.  Calling on this function will return a list of mailboxes.
  * This method receives the host argument automatically via $this->connect in the
  * $this->mailboxInfo['host'] variable if a connection URI is used.
  *
  * @param    string  (optional) host name.
  * @return   array|false   list of mailboxes on the current server.
  * @access   public
  * @see      imap_list
  * @tutorial http://www.smilingsouls.net/Mail_IMAP?content=Mail_IMAP/getMailboxes
  */
 function getMailboxes($host = null, $pattern = '*', $rtn = true)
 {
     if (empty($host) && !isset($this->mailboxInfo['host'])) {
         $this->error->push(Mail_IMAPv2_ERROR, 'error', null, 'Supplied host is not valid!');
         return false;
     } else {
         if (empty($host) && isset($this->mailboxInfo['host'])) {
             $host = $this->mailboxInfo['host'];
         }
     }
     if ($list = @imap_list($this->mailbox, $host, $pattern)) {
         if (is_array($list)) {
             foreach ($list as $key => $val) {
                 $mb[$key] = str_replace($host, '', imap_utf7_decode($val));
             }
         }
     } else {
         $this->error->push(Mail_IMAPv2_ERROR, 'error', null, 'Cannot fetch mailbox names.');
         return false;
     }
     if ($rtn) {
         return $mb;
     } else {
         $this->mailboxInfo = array_merge($this->mailboxInfo, $mb);
     }
 }