当前位置: 首页>>代码示例>>PHP>>正文


PHP Horde_Mime_Part::toString方法代码示例

本文整理汇总了PHP中Horde_Mime_Part::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Part::toString方法的具体用法?PHP Horde_Mime_Part::toString怎么用?PHP Horde_Mime_Part::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Horde_Mime_Part的用法示例。


在下文中一共展示了Horde_Mime_Part::toString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fullMessageText

 /**
  * 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+');
 }
开发者ID:horde,项目名称:horde,代码行数:28,代码来源:Contents.php

示例2: testBug10431

    public function testBug10431()
    {
        $text = 'Das könnte zum Beispiel so aussehen, dass wir bei entsprechenden Anfragen diese an eine Kontaktperson bei Euch weiterleiten. Oder Ihr schnürt ein entsprechendes Paket, dass wir in unseren Angeboten mit anführen. Bei erfolgreicher Vermittlung bekämen wir eine Vermittlungsgebühr.
Wir ständen dann weiterhin für 3rd-Level-Support zur Verfügung, d.h. für alle Anfragen des Kunden bzgl. Horde, die nicht zum Tagesgeschäft gehören.';
        $text = Horde_String::convertCharset($text, 'UTF-8', 'ISO-8859-1');
        $textBody = new Horde_Mime_Part();
        $textBody->setType('text/plain');
        $textBody->setCharset('ISO-8859-1');
        $flowed = new Horde_Text_Flowed($text, 'ISO-8859-1');
        $flowed->setDelSp(true);
        $textBody->setContents($flowed->toFlowed());
        $flowed_txt = $textBody->toString(array('headers' => false));
        $textBody2 = new Horde_Mime_Part();
        $textBody2->setType('text/plain');
        $textBody2->setCharset('ISO-8859-1');
        $textBody2->setContents($flowed_txt, array('encoding' => 'quoted-printable'));
        $flowed2 = new Horde_Text_Flowed($textBody2->getContents(), 'ISO-8859-1');
        $flowed2->setMaxLength(0);
        $flowed2->setDelSp(true);
        $this->assertEquals($text, trim($flowed2->toFixed()));
    }
开发者ID:jubinpatel,项目名称:horde,代码行数:21,代码来源:ComposeTest.php

示例3: replaceMime

 /**
  * Replace the MIME part of the message sent from the client.
  *
  * @param  Horde_Mime_Part $part  The new MIME part.
  * @since 2.19.0
  */
 public function replaceMime(Horde_Mime_Part $part)
 {
     $mime_stream = $part->toString(array('stream' => true, 'headers' => false));
     if (!empty($this->_header_text)) {
         $hdr = $this->_header_text;
     } else {
         $this->_stream->rewind();
         $hdr = $this->_stream->substring(0, $this->_hdr_pos);
     }
     $new_stream = Horde_Stream_Wrapper_Combine::getStream(array($hdr, $mime_stream));
     $this->_parseStream(new Horde_Stream_Existing(array('stream' => $new_stream)));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:18,代码来源:Rfc822.php

示例4: stripPart

 /**
  * Strips one or all MIME parts out of a message.
  *
  * @param string $partid  The MIME ID of the part to strip. All parts are
  *                        stripped if null.
  *
  * @return IMP_Indices  Returns the new indices object.
  * @throws IMP_Exception
  */
 public function stripPart($partid = null)
 {
     global $injector;
     list($mbox, $uid) = $this->getSingle();
     if (!$uid) {
         return;
     }
     if ($mbox->readonly) {
         throw new IMP_Exception(_("Cannot strip the part as the mailbox is read-only."));
     }
     $uidvalidity = $mbox->uidvalid;
     $contents = $injector->getInstance('IMP_Factory_Contents')->create($this);
     $message = $contents->getMIMEMessage();
     $boundary = trim($message->getContentTypeParameter('boundary'), '"');
     $url = new Horde_Imap_Client_Url();
     $url->mailbox = $mbox;
     $url->uid = $uid;
     $url->uidvalidity = $uidvalidity;
     $imp_imap = $mbox->imp_imap;
     /* Always add the header to output. */
     $url->section = 'HEADER';
     $parts = array(array('t' => 'url', 'v' => strval($url)));
     for ($id = 1;; ++$id) {
         if (!($part = $message[$id])) {
             break;
         }
         $parts[] = array('t' => 'text', 'v' => "\r\n--" . $boundary . "\r\n");
         if ($id != 1 && is_null($partid) || $id == $partid) {
             $newPart = new Horde_Mime_Part();
             $newPart->setType('text/plain');
             /* Need to make sure all text is in the correct charset. */
             $newPart->setCharset('UTF-8');
             $newPart->setContents(sprintf(_("[Part stripped: Original part type: %s, name: %s]"), $part->getType(), $contents->getPartName($part)));
             $newPart->setDisposition('attachment');
             $parts[] = array('t' => 'text', 'v' => $newPart->toString(array('canonical' => true, 'headers' => true, 'stream' => true)));
         } else {
             $url->section = $id . '.MIME';
             $parts[] = array('t' => 'url', 'v' => strval($url));
             $url->section = $id;
             $parts[] = array('t' => 'url', 'v' => strval($url));
         }
     }
     $parts[] = array('t' => 'text', 'v' => "\r\n--" . $boundary . "--\r\n");
     /* Get the headers for the message. */
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->imapDate();
     $query->flags();
     try {
         $res = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)))->first();
         if (is_null($res)) {
             throw new IMP_Imap_Exception();
         }
         $flags = $res->getFlags();
         /* If in Virtual Inbox, we need to reset flag to unseen so that it
          * appears again in the mailbox list. */
         if ($mbox->vinbox) {
             $flags = array_values(array_diff($flags, array(Horde_Imap_Client::FLAG_SEEN)));
         }
         $new_uid = $imp_imap->append($mbox, array(array('data' => $parts, 'flags' => $flags, 'internaldate' => $res->getImapDate())))->ids;
         $new_uid = reset($new_uid);
     } catch (IMP_Imap_Exception $e) {
         throw new IMP_Exception(_("An error occured while attempting to strip the part."));
     }
     $this->delete(array('keeplog' => true, 'nuke' => true));
     $indices_ob = $mbox->getIndicesOb($new_uid);
     /* We need to replace the old UID(s) in the URL params. */
     $vars = $injector->getInstance('Horde_Variables');
     if (isset($vars->buid)) {
         list(, $vars->buid) = $mbox->toBuids($indices_ob)->getSingle();
     }
     if (isset($vars->uid)) {
         $vars->uid = $new_uid;
     }
     return $indices_ob;
 }
开发者ID:horde,项目名称:horde,代码行数:84,代码来源:Indices.php

示例5: signAndEncryptPart

 /**
  * Signs and encrypts a MIME part using PGP.
  *
  * @param Horde_Mime_Part $part  The part to sign and encrypt.
  * @param mixed $privkey         The private key to use for signing (must
  *                               be decrypted).
  * @param array $opts            Additional options:
  *   - cipher: (string) Default symmetric cipher algorithm to use.
  *   - compress: (string) Default compression algorithm.
  *   - pubkeys: (mixed) The public key(s) to use for encryption.
  *   - symmetric: (string) If set, use as symmetric key.
  *
  * @return Horde_Mime_Part  A signed and encrypted part.
  * @throws Horde_Pgp_Exception
  */
 public function signAndEncryptPart(Horde_Mime_Part $part, $privkey, array $opts = array())
 {
     /* We use the combined method of sign & encryption in a single
      * OpenPGP packet (RFC 3156 [6.2]). */
     $signed = $this->sign($part->toString(array('canonical' => true, 'headers' => true)), $privkey, $opts);
     $base = $this->_encryptPart($signed->message, array_merge($opts, array('compress' => 'NONE')));
     $base->setDescription(Horde_Pgp_Translation::t("PGP Signed/Encrypted Data"));
     $base->setContents("This message is in MIME format and has been PGP signed and encrypted.\n");
     return $base;
 }
开发者ID:horde,项目名称:horde,代码行数:25,代码来源:Mime.php

示例6: replaceMime

 /**
  * Replace the MIME part of the message sent from the client. Headers from
  * the original message are always used.
  *
  * @param  Horde_Mime_Part $part  The new MIME part.
  * @since 2.19.0
  */
 public function replaceMime(Horde_Mime_Part $part)
 {
     $mime_stream = $part->toString(array('stream' => true, 'headers' => false));
     $mime_stream = new Horde_Stream_Existing(array('stream' => $mime_stream));
     // Since we are still using the headers sent from the device, we can
     // simply zero out the position members etc...
     $this->_hdr_pos = 0;
     $this->_stream = $mime_stream;
     $mime_stream->rewind();
 }
开发者ID:horde,项目名称:horde,代码行数:17,代码来源:Rfc822.php

示例7: _appendMessage

 /**
  * Append a new message.
  *
  * @param Horde_Mime_Part $message The message.
  * @param Horde_Mime_Headers $headers The message headers.
  *
  * @return boolean|string The return value of the append operation.
  * @throws Horde_Kolab_Storage_Object_Exception
  */
 protected function _appendMessage(Horde_Mime_Part $message, Horde_Mime_Headers $headers)
 {
     $result = $this->_getDriver()->appendMessage($this->_getFolder(), $message->toString(array('canonical' => true, 'stream' => true, 'headers' => $headers)));
     if (is_object($result) || $result === false || $result === null) {
         throw new Horde_Kolab_Storage_Object_Exception(sprintf('Unexpected return value (%s) when creating an object in folder "%s"!', print_r($result, true), $this->_getFolder()));
     }
     if ($result !== true) {
         $this->_backend_id = $result;
     }
     return $result;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:20,代码来源:Object.php

示例8: encryptMIMEPart

 /**
  * Encrypts a MIME part using PGP.
  *
  * @param Horde_Mime_Part $mime_part  The object to encrypt.
  * @param array $params               The parameters required for
  *                                    encryption
  *                                    ({@see _encryptMessage()}).
  *
  * @return mixed  A Horde_Mime_Part object that is encrypted according to
  *                RFC 3156.
  * @throws Horde_Crypt_Exception
  */
 public function encryptMIMEPart($mime_part, $params = array())
 {
     $params = array_merge($params, array('type' => 'message'));
     $signenc_body = $mime_part->toString(array('canonical' => true, 'headers' => true));
     $message_encrypt = $this->encrypt($signenc_body, $params);
     /* Set up MIME Structure according to RFC 3156. */
     $part = new Horde_Mime_Part();
     $part->setType('multipart/encrypted');
     $part->setHeaderCharset('UTF-8');
     $part->setContentTypeParameter('protocol', 'application/pgp-encrypted');
     $part->setDescription(Horde_Crypt_Translation::t("PGP Encrypted Data"));
     $part->setContents("This message is in MIME format and has been PGP encrypted.\n");
     $part1 = new Horde_Mime_Part();
     $part1->setType('application/pgp-encrypted');
     $part1->setCharset(null);
     $part1->setContents("Version: 1\n", array('encoding' => '7bit'));
     $part->addPart($part1);
     $part2 = new Horde_Mime_Part();
     $part2->setType('application/octet-stream');
     $part2->setCharset(null);
     $part2->setContents($message_encrypt, array('encoding' => '7bit'));
     $part2->setDisposition('inline');
     $part->addPart($part2);
     return $part;
 }
开发者ID:horde,项目名称:horde,代码行数:37,代码来源:Pgp.php

示例9: testMultipartDigest

 public function testMultipartDigest()
 {
     $part = new Horde_Mime_Part();
     $part->setType('multipart/digest');
     $part->isBasePart(true);
     $part2 = new Horde_Mime_Part();
     $part2->setType('message/rfc822');
     $part2->setContents(file_get_contents(__DIR__ . '/fixtures/sample_msg4.txt'));
     $part[] = $part2;
     $this->assertStringMatchesFormat("Content-Type: multipart/digest; boundary=\"=_%s\"\nMIME-Version: 1.0\n\nThis message is in MIME format.\n\n--=_%s\n\nMessage-ID: <asdl8ahwhoadsadl@example.com>\nDate: Tue, 07 Jul 2013 10:21:48 -0600\nFrom: \"Test Q. User\" <test@example.com>\nTo: foo@example.com\nSubject: Test\nMIME-Version: 1.0\n\n\nTest.\n\n--=_%s--", $part->toString(array('headers' => true)));
 }
开发者ID:x59,项目名称:horde-mime,代码行数:11,代码来源:PartTest.php

示例10: encryptMIMEPart

 /**
  * Encrypt a MIME part using S/MIME. This produces S/MIME Version 3.2
  * compatible data (see RFC 5751 [3.3]).
  *
  * @param Horde_Mime_Part $mime_part  The object to encrypt.
  * @param array $params               The parameters required for
  *                                    encryption.
  *
  * @return Horde_Mime_Part  An encrypted MIME part object.
  * @throws Horde_Crypt_Exception
  */
 public function encryptMIMEPart($mime_part, $params = array())
 {
     /* Sign the part as a message */
     $message = $this->encrypt($mime_part->toString(array('headers' => true, 'canonical' => true)), $params);
     $msg = new Horde_Mime_Part();
     $msg->setCharset($this->_params['email_charset']);
     $msg->setHeaderCharset('UTF-8');
     $msg->setDescription(Horde_Crypt_Translation::t("S/MIME Encrypted Message"));
     $msg->setDisposition('inline');
     $msg->setType('application/pkcs7-mime');
     $msg->setContentTypeParameter('smime-type', 'enveloped-data');
     $msg->setContents(substr($message, strpos($message, "\n\n") + 2), array('encoding' => 'base64'));
     return $msg;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:25,代码来源:Smime.php

示例11: _saveToSentMail

 /**
  * Save message to sent-mail mailbox, if configured to do so.
  *
  * @param Horde_Mime_Headers $headers     Headers object.
  * @param Horde_Mime_Part $save_msg       Message data to save.
  * @param Horde_Mail_Rfc822_List $recips  Recipient list.
  * @param array $opts                     See buildAndSendMessage()
  */
 protected function _saveToSentMail(Horde_Mime_Headers $headers, Horde_Mime_Part $save_msg, Horde_Mail_Rfc822_List $recips, $opts)
 {
     global $injector, $language, $notification, $prefs;
     if (empty($opts['sent_mail']) || $prefs->isLocked('save_sent_mail') && !$prefs->getValue('save_sent_mail') || !$prefs->isLocked('save_sent_mail') && empty($opts['save_sent'])) {
         return;
     }
     $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
     /* If message contains EAI addresses, we need to verify that the IMAP
      * server can handle this data in order to save. */
     foreach ($recips as $val) {
         if ($val->eai) {
             if ($imp_imap->client_ob->capability->query('UTF8', 'ACCEPT')) {
                 break;
             }
             $notification->push(sprintf(_("Message sent successfully, but not saved to %s."), $sent_mail->display));
             return;
         }
     }
     /* Strip attachments if requested. */
     if (!empty($opts['strip_attachments'])) {
         $save_msg->buildMimeIds();
         /* Don't strip any part if this is a text message with both
          * plaintext and HTML representation. */
         if ($save_msg->getType() != 'multipart/alternative') {
             for ($i = 2;; ++$i) {
                 if (!($oldPart = $save_msg[$i])) {
                     break;
                 }
                 $replace_part = new Horde_Mime_Part();
                 $replace_part->setType('text/plain');
                 $replace_part->setCharset($this->charset);
                 $replace_part->setLanguage($language);
                 $replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]');
                 $save_msg[$i] = $replace_part;
             }
         }
     }
     /* Generate the message string. */
     $fcc = $save_msg->toString(array('defserver' => $imp_imap->config->maildomain, 'headers' => $headers, 'stream' => true));
     /* Make sure sent mailbox is created. */
     $sent_mail = IMP_Mailbox::get($opts['sent_mail']);
     $sent_mail->create();
     $flags = array(Horde_Imap_Client::FLAG_SEEN, Horde_Imap_Client::FLAG_MDNSENT);
     try {
         $imp_imap->append($sent_mail, array(array('data' => $fcc, 'flags' => $flags)));
     } catch (IMP_Imap_Exception $e) {
         $notification->push(sprintf(_("Message sent successfully, but not saved to %s."), $sent_mail->display));
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:57,代码来源:Compose.php

示例12: testQuotedPrintableNewlines

 public function testQuotedPrintableNewlines()
 {
     $part = new Horde_Mime_Part();
     $part->setType('text/plain');
     $part->setContents("A\r\nBā\r\nC");
     $this->assertEquals("A\r\nB=C4=81\r\nC", $part->toString());
     $part->setEOL("\r\n");
     $this->assertEquals("A\r\nB=C4=81\r\nC", $part->toString());
     $part2 = new Horde_Mime_Part();
     $part2->setType('multipart/mixed');
     $part2->addPart($part);
     $this->assertStringMatchesFormat("This message is in MIME format.\n\n--=_%s\nContent-Type: text/plain\nContent-Transfer-Encoding: quoted-printable\n\nA\nB=C4=81\nC\n--=_%s--", $part2->toString());
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:13,代码来源:PartTest.php

示例13: append

 /**
  * 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);
 }
开发者ID:horde,项目名称:horde,代码行数:45,代码来源:Draft.php


注:本文中的Horde_Mime_Part::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。