public function testUsage() { $fp = fopen('php://temp', 'r+'); fwrite($fp, '12345'); $data = array('ABCDE', $fp, 'fghij'); $stream = Horde_Stream_Wrapper_Combine::getStream($data); $this->assertEquals('ABCDE12345fghij', fread($stream, 1024)); $this->assertEquals(true, feof($stream)); $this->assertEquals(0, fseek($stream, 0)); $this->assertEquals(-1, fseek($stream, 0)); $this->assertEquals(0, ftell($stream)); $this->assertEquals(0, fseek($stream, 5, SEEK_CUR)); $this->assertEquals(5, ftell($stream)); $this->assertEquals(10, fwrite($stream, '0000000000')); $this->assertEquals(0, fseek($stream, 0, SEEK_END)); $this->assertEquals(20, ftell($stream)); $this->assertEquals(false, feof($stream)); fclose($stream); }
/** * Return the raw message data. * * @return stream resource */ public function getString() { if (!empty($this->_header_text)) { return Horde_Stream_Wrapper_Combine::getStream(array($this->_header_text, $this->getMessage()->stream)); } else { $this->_stream->rewind(); return $this->_stream->stream; } }
/** * Returns the full message text. * * @param array $options Additional options: * - stream: (boolean) If true, return a stream for bodytext. * DEFAULT: No * * @return mixed The full message text or a stream resource if 'stream' * is true. */ public function fullMessageText($options = array()) { if (!$this->_indices) { return $this->_message->toString(); } $query = new Horde_Imap_Client_Fetch_Query(); $query->bodyText(array('peek' => true)); if ($res = $this->_fetchData($query)) { try { if (empty($options['stream'])) { return $this->getHeader(self::HEADER_TEXT) . $res->getBodyText(0); } return Horde_Stream_Wrapper_Combine::getStream(array($this->getHeader(self::HEADER_STREAM), $res->getBodyText(0, true))); } catch (Horde_Exception $e) { } } return empty($options['stream']) ? '' : fopen('php://temp', 'r+'); }
/** * Get the raw email data sent by this object. * * @param boolean $stream If true, return a stream resource, otherwise * a string is returned. * * @return stream|string The raw email data. * @since 2.4.0 */ public function getRaw($stream = true) { if ($stream) { $hdr = new Horde_Stream(); $hdr->add($this->_headers->toString(), true); return Horde_Stream_Wrapper_Combine::getStream(array($hdr->stream, $this->getBasePart()->toString(array('stream' => true)))); } return $this->_headers->toString() . $this->_getBasePart->toString(); }
/** * Get the raw email data sent by this object. * * @param boolean $stream If true, return a stream resource, otherwise * a string is returned. * * @return stream|string The raw email data. * @since 2.4.0 */ public function getRaw($stream = true) { if ($stream) { $hdr = new Horde_Stream(); $hdr->add($this->_headers->toString(), true); return Horde_Stream_Wrapper_Combine::getStream(array($hdr->stream, $this->getBasePart()->toString(array('stream' => true, 'encode' => Horde_Mime_Part::ENCODE_7BIT | Horde_Mime_Part::ENCODE_8BIT | Horde_Mime_Part::ENCODE_BINARY)))); } return $this->_headers->toString() . $this->getBasePart()->toString(); }
/** */ public function send($recipients, array $headers, $body) { /* If we don't already have an SMTP object, create one. */ $this->getSMTPObject(); $headers = $this->_sanitizeHeaders($headers); list($from, $textHeaders) = $this->prepareHeaders($headers); $from = $this->_getFrom($from, $headers); $combine = Horde_Stream_Wrapper_Combine::getStream(array(rtrim($textHeaders, $this->sep), $this->sep . $this->sep, $body)); try { $this->_smtp->send($from, $recipients, $combine); } catch (Horde_Smtp_Exception $e) { throw new Horde_Mail_Exception($e); } }