/** * Find the location of the end of the header text. * * @return array 1st element: Header position, 2nd element: Length of * trailing EOL. */ protected function _findHeader() { // Look for the EOL that is found first in the message. Some clients // are sending mixed EOL in S/MIME signed messages. This still doesn't // fix "Nine" currently, as they first send \r\n, but use \n\n to // separate the headers. // See: https://ninefolders.plan.io/track/10606/1dcfed switch ($this->_stream->getEOL()) { case "\n": return array($this->_stream->search("\n\n"), 2); case "\r\n": return array($this->_stream->search("\r\n\r\n"), 4); } }
/** * Sends a redirect (a/k/a resent) message. * * @param Horde_Stream $message Message content. * * @throws Horde_Spam_Exception */ protected function _redirectMessage(Horde_Stream $message) { /* Split up headers and message. */ $message->rewind(); $eol = $message->getEOL(); $headers = $message->getToChar($eol . $eol); if (!strlen($headers)) { throw new Horde_Spam_Exception('Invalid message reported, header not found'); } $body = fopen('php://temp', 'r+'); stream_copy_to_stream($message->stream, $body, -1, $message->pos()); /* We need to set the Return-Path header to the sending user - see RFC * 2821 [4.4]. */ $headers = preg_replace('/return-path:.*?(\\r?\\n)/i', 'Return-Path: <' . $this->_from_addr . '>$1', $headers); try { $this->_mail->send($this->_email, array('_raw' => $headers, 'from' => $this->_from_addr), $body); } catch (Horde_Mail_Exception $e) { $this->_logger->warn($e); throw new Horde_Spam_Exception($e); } }