/** * 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; } }