function DebugEmailOutput($email, $mimeDecodedEmail) { if (IsDebugMode()) { //DebugDump($email); //DebugDump($mimeDecodedEmail); $dname = POSTIE_ROOT . DIRECTORY_SEPARATOR . "test_emails" . DIRECTORY_SEPARATOR; if (is_dir($dname)) { $fname = $dname . sanitize_file_name($mimeDecodedEmail->headers["message-id"]); $file = fopen($fname . ".txt ", "w"); fwrite($file, $email); fclose($file); $file = fopen($fname . "-mime.txt ", "w"); fwrite($file, print_r($mimeDecodedEmail, true)); fclose($file); $file = fopen($fname . ".php ", "w"); fwrite($file, serialize($email)); fclose($file); } } }
//support moving wp-config.php as described here http://codex.wordpress.org/Hardening_WordPress#Securing_wp-config.php $wp_config_path = dirname(dirname(dirname(dirname(__FILE__)))); if (file_exists($wp_config_path . DIRECTORY_SEPARATOR . "wp-config.php")) { include_once $wp_config_path . DIRECTORY_SEPARATOR . "wp-config.php"; } else { include_once dirname($wp_config_path) . DIRECTORY_SEPARATOR . "wp-config.php"; } require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mimedecode.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-functions.php'; if (!function_exists('file_get_html')) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'simple_html_dom.php'; } EchoInfo("Starting mail fetch"); EchoInfo("Postie Version: " . POSTIE_VERSION); EchoInfo("Debug mode: " . (IsDebugMode() ? "On" : "Off")); EchoInfo("Time: " . date('Y-m-d H:i:s', time()) . " GMT"); $wp_content_path = dirname(dirname(dirname(__FILE__))); DebugEcho("wp_content_path: {$wp_content_path}"); if (file_exists($wp_content_path . DIRECTORY_SEPARATOR . "filterPostie.php")) { DebugEcho("found filterPostie.php in {$wp_content_path}"); include_once $wp_content_path . DIRECTORY_SEPARATOR . "filterPostie.php"; } $test_email = null; $config = config_Read(); extract($config); if (!isset($maxemails)) { $maxemails = 0; } $emails = FetchMail($mail_server, $mail_server_port, $mail_userid, $mail_password, $input_protocol, $time_offset, $test_email, $delete_mail_after_processing, $maxemails, $email_tls); $message = 'Done.';
/** * Gets the raw email message from the server * @return string */ function fetchEmail($index) { $header_info = imap_headerinfo($this->_connection, $index); if (IsDebugMode() || $header_info->Recent == 'N' || $header_info->Unseen == 'U') { $email = imap_fetchheader($this->_connection, $index); $email .= imap_body($this->_connection, $index); return $email; } else { return 'already read'; } }