/** * Logs the specified error * * @access public * @param mixed $error_msg The error message * @param string $script The script name where the error happened * @param integer $line The line number where the error happened */ function logError($error_msg = "", $script = "", $line = "") { if (REPORT_ERROR_FILE) { Error_Handler::logToFile($error_msg, $script, $line); } $setup = Setup::load(); if (@$setup['email_error']['status'] == 'enabled') { // if there's no db_api object, then we cannot // possibly queue up the error emails if (!is_null(@$GLOBALS["db_api"])) { Error_Handler::_notify($error_msg, $script, $line); } } }
/** * Connects to the SMTP server and sends the queued message. * * @access private * @param string $recipient The recipient of this message * @param string $text_headers The full headers of this message * @param string $body The full body of this message * @return true, or a PEAR_Error object */ function _sendEmail($recipient, $text_headers, $body) { $header_names = Mime_Helper::getHeaderNames($text_headers); $_headers = Mail_Queue::_getHeaders($text_headers, $body); $headers = array(); foreach ($_headers as $lowercase_name => $value) { // need to remove the quotes to avoid a parsing problem // on senders that have extended characters in the first // or last words in their sender name if ($lowercase_name == 'from') { $value = Mime_Helper::removeQuotes($value); } $value = Mime_Helper::encode($value); // add the quotes back if ($lowercase_name == 'from') { $value = Mime_Helper::quoteSender($value); } $headers[$header_names[$lowercase_name]] = $value; } // remove any Reply-To:/Return-Path: values from outgoing messages unset($headers['Reply-To']); unset($headers['Return-Path']); // mutt sucks, so let's remove the broken Mime-Version header and add the proper one if (in_array('Mime-Version', array_keys($headers))) { unset($headers['Mime-Version']); $headers['MIME-Version'] = '1.0'; } $mail =& Mail::factory('smtp', Mail_API::getSMTPSettings()); $res = $mail->send($recipient, $headers, $body); if (PEAR::isError($res)) { // special handling of errors when the mail server is down if (strstr($res->getMessage(), 'unable to connect to smtp server')) { Error_Handler::logToFile(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); } else { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); } return $res; } else { return true; } }