示例#1
0
                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
                // posterity and should not be parsed and downloaded and re-emailed etc.
                if (same_email_address($email_receive->mail_headers["from"], ALLOC_DEFAULT_FROM_ADDRESS)) {
                    $email_receive->mark_seen();
                    $email_receive->archive();
                } else {
                    inbox::process_one_email($email_receive);
                }
            }
        } catch (Exception $e) {
            // There may have been a database error, so let the database know it can run this next bit
            db_alloc::$stop_doing_queries = false;
            // Try forwarding the errant email
            try {
                $email_receive->forward(config::get_config_item("allocEmailAdmin"), "Email command failed", "\n" . $e->getMessage() . "\n\n" . $e->getTraceAsString());
                // If that fails, try last-ditch email send
            } catch (Exception $e) {
                mail(config::get_config_item("allocEmailAdmin"), "Email command failed(2)", "\n" . $e->getMessage() . "\n\n" . $e->getTraceAsString());
            }
        }
    }
}
示例#2
0
 function process_email($req = array())
 {
     global $TPL;
     $info = inbox::get_mail_info();
     $email_receive = new email_receive($info);
     $email_receive->open_mailbox($info["folder"]);
     $email_receive->set_msg($req["id"]);
     $email_receive->get_msg_header();
     inbox::process_one_email($email_receive);
     $email_receive->expunge();
     $email_receive->close();
 }