コード例 #1
0
ファイル: receiveEmail.php プロジェクト: cjbayliss/alloc
if (!$info["host"]) {
    alloc_error("Email mailbox host not defined, assuming email receive function is inactive.", true);
}
$email_receive = new email_receive($info);
$email_receive->open_mailbox(config::get_config_item("allocEmailFolder"));
$email_receive->check_mail();
$num_new_emails = $email_receive->get_num_new_emails();
if ($num_new_emails > 0) {
    $msg_nums = $email_receive->get_new_email_msg_uids();
    print $nl . date("Y-m-d H:i:s") . " Found " . count($msg_nums) . " new/unseen emails." . $nl;
    foreach ($msg_nums as $num) {
        // Errors from previous iterations shouldn't affect processing of the next email
        db_alloc::$stop_doing_queries = false;
        $email_receive->set_msg($num);
        $email_receive->get_msg_header();
        $keys = $email_receive->get_hashes();
        try {
            // If no keys
            if (!$keys) {
                // If email sent from a known staff member
                $from_staff = inbox::change_current_user($email_receive->mail_headers["from"]);
                if ($from_staff) {
                    inbox::convert_email_to_new_task($email_receive, true);
                } else {
                    $email_receive->mark_seen();
                    // mark it seen so we don't poll for it again
                    alloc_error("Could not create a task from this email. Email was not sent by a staff member. Email resides in INBOX.");
                }
                // Else if we have a key, append to comment
            } else {
                // Skip over emails that are from alloc. These emails are kept only for
コード例 #2
0
ファイル: patch-00179-alla.php プロジェクト: cjbayliss/alloc
 // this will stream output
 flush();
 $dir = ATTACHMENTS_DIR . "tmp";
 if (!is_dir($dir)) {
     mkdir($dir);
 }
 usleep(25000);
 $x++;
 #$x>20 and alloc_error(fclose($fp).$mail->close()."\n"."Stopped."."\n");
 $mail->set_msg($num);
 $decoded = $mail->save_email();
 $body = trim(mime_parser::get_body_text($decoded));
 $from = $decoded[0]["Headers"]["from:"];
 $subject = $decoded[0]["Headers"]["subject:"];
 $messageid = $decoded[0]["Headers"]["message-id:"];
 $keys = $mail->get_hashes();
 printorlog("\n");
 printorlog($x . ". " . date("Y-m-d H:i:s") . " Keys:" . print_r($keys, 1) . " IMAP UID: " . $num);
 // Get a bunch of comments that look like they might belong to this email...
 unset($q);
 // First try and get a Key: from the subject line, or message-id
 $key = current($keys);
 if ($key && strlen($key) == 8) {
     $db->query("SELECT * FROM token WHERE tokenHash = '%s'", $key);
     $row = $db->row();
     printorlog("Using key: " . $key . " relates to: " . $row["tokenEntity"] . ":" . $row["tokenEntityID"]);
     // lookup the entity for that key eg: comment 1234 or task 123
     if ($row) {
         $q = prepare("SELECT * \n                        FROM comment \n                       WHERE commentEmailUID IS NULL \n                         AND ((commentID = %d AND '%s'='comment') OR (commentLinkID = %d AND commentType='%s'))", $row["tokenEntity"], $row["tokenEntityID"], $row["tokenEntityID"], $row["tokenEntity"]);
     }
     // Failing a key, try and get a "Task Comment: 213" from the email subject