function archive_email($req = array()) { global $TPL; $info = inbox::get_mail_info(); $email_receive = new email_receive($info); $email_receive->open_mailbox($info["folder"]); $mailbox = "INBOX/archive" . date("Y"); $email_receive->create_mailbox($mailbox) and $TPL["message_good"][] = "Created mailbox: " . $mailbox; $email_receive->move_mail($req["id"], $mailbox) and $TPL["message_good"][] = "Moved email " . $req["id"] . " to " . $mailbox; $email_receive->close(); }
$row = $db->qr("SELECT count(*) AS sum FROM comment WHERE commentCreatedTime >= '2012-05-12 00:00:00'"); //e(sprintf("Found %d comments created.",$row["sum"])); $info["host"] = config::get_config_item("allocEmailHost"); $info["port"] = config::get_config_item("allocEmailPort"); $info["username"] = config::get_config_item("allocEmailUsername"); $info["password"] = config::get_config_item("allocEmailPassword"); $info["protocol"] = config::get_config_item("allocEmailProtocol"); $qid = $db->query("SELECT * FROM comment WHERE commentCreatedTime >= '2012-05-12 00:00:00'"); while ($row = $db->row($qid)) { // For each comment, ascertain the taskID $entity = $row["commentMaster"]; $entityID = $row["commentMasterID"]; // Use the taskID to query the mbox.taskID for all its emails $mail = new email_receive($info); $mail->open_mailbox("INBOX"); $created = $mail->create_mailbox("INBOX/" . $entity . $entityID); $created or $created = $mail->create_mailbox("INBOX." . $entity . $entityID); $opened = $mail->open_mailbox("INBOX/" . $entity . $entityID); $uids = $mail->get_all_email_msg_uids(); //e("Entity: ".$entity.$entityID." comment: ".$row["commentID"]." uids: ".print_r($uids,1)); $found = false; foreach ((array) $uids as $uid) { // If there's one that looks like the current one, forgeddaboutit list($header, $body) = $mail->get_raw_email_by_msg_uid($uid); similar_text(preg_replace("/\\s+/", "", trim($row["comment"])), preg_replace("/\\s+/", "", trim($body)), $percent); if ($percent > 97) { $found = true; #e("percent: ".$percent); #e("1-------------------"); #e($row["comment"]); #e("2-------------------");
$x++; // this will stream output flush(); $mail->set_msg($num); $mail->get_msg_header($num); $keys = $mail->get_hashes(); $mailbox = hash_to_entity($keys[0]); if (!$mailbox) { printorlog("\n"); printorlog("keys[0] not found. Trying keys[1]: "); $mailbox = hash_to_entity($keys[1]); if (!$mailbox) { printorlog("Failed: " . print_r($keys, 1)); continue; } } printorlog("\n"); printorlog("INBOX." . $mailbox); $mail->create_mailbox("INBOX/" . $mailbox); $mail->move_mail($num, "INBOX/" . $mailbox); if ($x % 100 == 0) { printorlog("\n"); printorlog("expunging at " . $x); $mail->expunge(); } } printorlog("\n"); printorlog("Done at " . $x); $mail->expunge(); $mail->close(); printorlog(date("Y-m-d H:i:s") . " DONE.");