addMimeHeaders() public méthode

Returns a Horde_Mime_Header object containing all MIME headers needed for the part.
public addMimeHeaders ( array $options = [] ) : Horde_Mime_Headers
$options array Additional options: - encode: (integer) A mask of allowable encodings. DEFAULT: Auto-determined - headers: (Horde_Mime_Headers) The object to add the MIME headers to. DEFAULT: Add headers to a new object
Résultat Horde_Mime_Headers A Horde_Mime_Headers object.
Exemple #1
0
 /**
  * Returns base header information.
  *
  * @param integer $type  See getHeader().
  * @param boolean $seen  Mark message as seen?
  *
  * @return mixed  See getHeader().
  */
 protected function _getHeader($type, $seen)
 {
     if (!isset($this->_header)) {
         if (!$this->_indices) {
             $this->_header = $this->_message->addMimeHeaders();
         } else {
             $query = new Horde_Imap_Client_Fetch_Query();
             $query->headerText(array('peek' => !$seen));
             $this->_header = ($res = $this->_fetchData($query)) ? $res : new Horde_Imap_Client_Data_Fetch();
         }
     }
     switch ($type) {
         case self::HEADER_OB:
             return $this->_indices ? $this->_header->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE) : $this->_header;
         case self::HEADER_TEXT:
             return $this->_indices ? $this->_header->getHeaderText() : $this->_header->toString();
         case self::HEADER_STREAM:
             if ($this->_indices) {
                 return $this->_header->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_STREAM);
             }
             $stream = new Horde_Support_StringStream($this->_header->toString());
             $stream->fopen();
             return $stream;
     }
 }
Exemple #2
0
    public function testBug13709()
    {
        $p_part = new Horde_Mime_Part();
        $p_part->setType('text/plain');
        $p_part->setContents('Foo bär');
        $h_part = new Horde_Mime_Part();
        $h_part->setType('text/html');
        $h_part->setContents('Foo<br />
<br />
&quot;smith, Jane (IAM)&quot; &lt;<a href="mailto:Jane.smith@kit.edu">Jane.smith@kit.edu</a>&gt; wrote:<br />
<br />
<blockquote type="cite" style="border-left:2px solid blue;margin-left:2px;padding-left:12px;"><html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hallo Jörk,<div><br></div><div>hoffe es geht dir gut und bei HHHH ist alles okay?</div><div><br></div><div>Ich wollte gerade auf die XXX III Homepage schauen und haben im Browser nur <a href="http://example.com">example.com</a> eingegeben.</div><div>Damit bin ich auf einer Seite mit XXX II - Logo gelandet, die sofort Passwort und Nutzername abgefragt hat.</div><div>Ist diese Seite auch von Euch?</div><div><br></div><div>Liebe Grüße,</div><div>Jane</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><div>
<div><div style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 10px;">--------------------------------------------------<br>Dr. Jane smith</div><div style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 10px;">( geb. Repper)<br>Karlsruhe Institute of Technology (KIT)&nbsp;<br>IAM-WK@INT&nbsp;<br>Hermann-von-Helmholtz-Platz 1, Building 640,&nbsp;</div><div style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 10px;">76344&nbsp;Eggenstein-Leopoldshafen, Germany<br><br>Phone CN: +49 721 608-26960</div><div style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 10px;">Phone CS: +49 721 608-47447<br>Web:&nbsp;<a href="http://www.kit.edu/">http://www.kit.edu/</a>&nbsp;<br><br>KIT – University of the State of Baden-Wuerttemberg&nbsp;and<br>National Research Center of the Helmholtz&nbsp;Association</div></div>
</div>
<br></div></body></html></blockquote><br /><br />');
        $base_part = new Horde_Mime_Part();
        $base_part->setType('multipart/alternative');
        $base_part[] = $p_part;
        $base_part[] = $h_part;
        $headers = $base_part->addMimeHeaders();
        $headers->addHeader('From', '*****@*****.**');
        $headers->addHeader('Subject', 'My Subject');
        $mailer = new Horde_Mail_Transport_Mock();
        $base_part->send('*****@*****.**', $headers, $mailer, array('encode' => Horde_Mime_Part::ENCODE_8BIT));
        $sent = current($mailer->sentMessages);
        $sent_mime = Horde_Mime_Part::parseMessage($sent['header_text'] . "\n\n" . $sent['body']);
        $headers = Horde_Mime_Headers::parseHeaders($sent_mime[$sent_mime->findBody('plain')]->toString(array('headers' => true, 'encode' => Horde_Mime_Part::ENCODE_8BIT)));
        $this->assertEquals('8bit', $headers->getHeader('Content-Transfer-Encoding')->value_single);
        $headers = Horde_Mime_Headers::parseHeaders($sent_mime[$sent_mime->findBody('html')]->toString(array('headers' => true, 'encode' => Horde_Mime_Part::ENCODE_8BIT)));
        $this->assertEquals('quoted-printable', $headers->getHeader('Content-Transfer-Encoding'));
    }
Exemple #3
0
 /**
  * Append the current Draft message to the IMAP server.
  *
  * @return array  An array with the following keys:
  *     - uid: (integer)   The new draft message's IMAP UID.
  *     - atchash: (array) An attachment hash of newly added attachments.
  */
 public function append($folderid)
 {
     // Init
     $atc_map = array();
     $atc_hash = array();
     // Create the wrapper part.
     $base = new Horde_Mime_Part();
     $base->setType('multipart/mixed');
     // Check to see if we have any existing parts to add.
     if (!empty($this->_imapMessage)) {
         foreach ($this->_imapMessage->getStructure() as $part) {
             if ($part->isAttachment() && !in_array($part->getMimeId(), $this->_atcDelete)) {
                 $base->addPart($this->_imapMessage->getMimePart($part->getMimeId()));
             }
         }
     }
     // Add body
     $base->addPart($this->_textPart);
     // Add Mime headers
     $base->addMimeHeaders(array('headers' => $this->_headers));
     foreach ($this->_atcAdd as $atc) {
         $base->addPart($atc);
         $atc_map[$atc->displayname] = $atc->clientid;
     }
     $stream = $base->toString(array('stream' => true, 'headers' => $this->_headers->toString()));
     $new_uid = $this->_imap->appendMessage($folderid, $stream, array('\\draft', '\\seen'));
     foreach ($base as $part) {
         if ($part->isAttachment() && !empty($atc_map[$part->getName()])) {
             $atc_hash['add'][$atc_map[$part->getName()]] = $folderid . ':' . $stat['id'] . ':' . $part->getMimeId();
         }
     }
     // If we pulled down an existing Draft, delete it now since the
     // new one will replace it.
     if (!empty($this->_imapMessage)) {
         $this->_imap->deleteMessages(array($this->_draftUid), $folderid);
     }
     return array('uid' => $new_uid, 'atchash' => $atc_hash);
 }