$mail->open_mailbox(config::get_config_item("allocEmailFolder") . "/" . $entity . $entityID); if ($_REQUEST["uid"]) { header('Content-Type: text/plain; charset=utf-8'); list($h, $b) = $mail->get_raw_email_by_msg_uid($_REQUEST["uid"]); $mail->close(); echo $h . $b; exit; } //$uids = $mail->get_all_email_msg_uids(); $t = new token(); $t->select_token_by_entity_and_action($c->get_value("commentType"), $c->get_value("commentLinkID"), "add_comment_from_email"); $hash = $t->get_value("tokenHash"); // First try a messageID search if ($c->get_value("commentEmailMessageID")) { $str = sprintf('TEXT "%s"', $c->get_value("commentEmailMessageID")); $uids = $mail->get_emails_UIDs_search($str); if (count($uids) == 1) { alloc_redirect($TPL["url_alloc_downloadEmail"] . "commentID=" . $_REQUEST["commentID"] . "&uid=" . $uids[0]); } else { if (count($uids) > 1) { $all_uids += $uids; } } } // Next try a hash lookup if ($hash) { $str = sprintf('TEXT "%s"', $hash); $uids = $mail->get_emails_UIDs_search($str); $uids and $all_uids += $uids; } $str = sprintf('FROM "%s" ', $c->get_value("commentCreatedUserText"));
} // Tests if (basename($_SERVER["PHP_SELF"]) == "email_receive.inc.php") { define("NO_AUTH", 1); require_once "alloc.php"; //require_once("emailsettings.php"); $num = 30; $e = new email_receive($info); $e->open_mailbox("INBOX"); echo "\nNum emails: " . $e->get_num_emails(); echo "\nNew emails: " . $e->get_num_new_emails(); echo "\ncheck_mail(): " . str_replace("\n", " ", print_r($e->mail_info, 1)); echo "\nget_new_email_msg_uids(): " . str_replace("\n", " ", print_r($e->get_new_email_msg_uids(), 1)); echo "\nget_all_email_msg_uids(): " . str_replace("\n", " ", print_r($e->get_all_email_msg_uids(), 1)); //exit(); echo "\nget_emails_UIDs_search(): " . str_replace("\n", " ", print_r($e->get_emails_UIDs_search("SUBJECT alloc"), 1)); //echo "\nget_msg_header(): ".str_replace("\n"," ",print_r($e->get_msg_header($num),1)); echo "\n"; $e->set_msg($num); $e->load_structure(); echo "\nload_structure(): " . str_replace(" ", " ", print_r($e->mail_structure, 1)); echo "\nget_charset(): " . $e->get_charset(); //exit(); list($h, $b) = $e->get_raw_email_by_msg_uid($num); //echo "\nget_raw_email_by_msg_uid(): "."HEADER: ".$h."\nBODY: ".$b; echo "\nsave_email(): " . $e->save_email(); //echo "\nload_parts(): ".print_r($e->mail_parts,1); echo "\nmail_text (plaintext version): " . $e->mail_text; echo "\nget_commands(): " . print_r($e->get_commands(task::get_exposed_fields()), 1); echo "\n"; }
/** * Get a list of IMAP email UIDs, based on a string search * @param string $str the search string * @return array an array of email UIDs */ public function get_comment_email_uids_search($str) { if ($str) { $current_user =& singleton("current_user"); $info = $this->init_email_info(); $mail = new email_receive($info); $mail->open_mailbox(config::get_config_item("allocEmailFolder"), OP_READONLY); $rtn = $mail->get_emails_UIDs_search($str); $mail->close(); } return (array) $rtn; }