getRawHeader example


    public function getMessage($id)
    {
        // TODO that's ugly, would be better to let the message class decide         if (strtolower($this->_messageClass) == 'zend_mail_message_file' || is_subclass_of($this->_messageClass, 'zend_mail_message_file')) {
            return new $this->_messageClass(array('file'  => $this->_getFileData($id, 'filename'),
                                                  'flags' => $this->_getFileData($id, 'flags')));
        }

        return new $this->_messageClass(array('handler' => $this, 'id' => $id, 'headers' => $this->getRawHeader($id),
                                              'flags'   => $this->_getFileData($id, 'flags')));
    }

    /* * Get raw header of message or part * * @param int $id number of message * @param null|array|string $part path to part or null for messsage header * @param int $topLines include this many lines with header (after an empty line) * @return string raw header * @throws Zend_Mail_Storage_Exception */

    public function getHeaders()
    {
        if ($this->_headers === null) {
            if (!$this->_mail) {
                $this->_headers = array();
            } else {
                $part = $this->_mail->getRawHeader($this->_messageNum);
                Zend_Mime_Decode::splitMessage($part$this->_headers, $null);
            }
        }

        return $this->_headers;
    }

    /** * Get a header in specificed format * * Internally headers that occur more than once are saved as array, all other as string. If $format * is set to string implode is used to concat the values (with Zend_Mime::LINEEND as delim). * * @param string $name name of header, matches case-insensitive, but camel-case is replaced with dashes * @param string $format change type of return value to 'string' or 'array' * @return string|array value of header in wanted or internal format * @throws Zend_Mail_Exception */

        // TODO that's ugly, would be better to let the message class decide         if (strtolower($this->_messageClass) == 'zend_mail_message_file' || is_subclass_of($this->_messageClass, 'zend_mail_message_file')) {
            // TODO top/body lines             $messagePos = $this->_getPos($id);
            return new $this->_messageClass(array('file' => $this->_fh, 'startPos' => $messagePos['start'],
                                                  'endPos' => $messagePos['end']));
        }

        $bodyLines = 0; // TODO: need a way to change that
        $message = $this->getRawHeader($id);
        // file pointer is after headers now         if ($bodyLines) {
            $message .= "\n";
            while ($bodyLines-- && ftell($this->_fh) < $this->_positions[$id - 1]['end']) {
                $message .= fgets($this->_fh);
            }
        }

        return new $this->_messageClass(array('handler' => $this, 'id' => $id, 'headers' => $message));
    }

    
Home | Imprint | This part of the site doesn't use cookies.