} 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()); } } } } $email_receive->expunge(); $email_receive->close();
function alloc_error($str = "", $force = null) { $errors_logged =& singleton("errors_logged"); $errors_thrown =& singleton("errors_thrown"); $errors_fatal =& singleton("errors_fatal"); isset($force) and $errors_fatal = $force; // permit override $errors_format =& singleton("errors_format"); $errors_format or $errors_format = "html"; $errors_haltdb =& singleton("errors_haltdb"); // Load up a nicely rendered html error if ($errors_format == "html") { global $TPL; $TPL["message"][] = $str; } // Output a plain-text error suitable for logfiles and CLI if ($errors_format == "text" && ini_get('display_errors')) { echo strip_tags($str); } // Log the error message if ($errors_logged) { error_log(strip_tags($str)); } // Prevent further db queries if ($errors_haltdb) { db_alloc::$stop_doing_queries = true; } // Throw an exception, that can be caught and handled (eg receiveEmail.php) if ($errors_thrown) { throw new Exception(strip_tags($str)); } // Print message to a blank webpage (eg tools/backup.php) if ($force) { echo $str; } // If it was a serious error, then halt if ($errors_fatal) { exit(1); // exit status matters to pipeEmail.php } }