Fetch a part of a MIME message.
public getMimePart ( integer $id, array $options = [] ) : Horde_Mime_Part | ||
$id | integer | The MIME index of the part requested. |
$options | array | Additional options: - length: (integer) If set, only download this many bytes of the bodypart from the server. DEFAULT: All data is retrieved. - nocontents: (boolean) If true, don't add the contents to the part DEFAULT: Contents are added to the part |
리턴 | Horde_Mime_Part | The raw MIME part asked for. |
/** * 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); }
/** * Return the content of a specific MIME part of the specified message. * * @param string $mailbox The mailbox name. * @param string $uid The message UID. * @param string $part The MIME part identifier. * * @return Horde_Mime_Part The attachment data * * @throws Horde_ActiveSync_Exception */ public function getAttachment($mailbox, $uid, $part) { $imap = $this->_getImapOb(); $mbox = new Horde_Imap_Client_Mailbox($mailbox); $messages = $this->_getMailMessages($mbox, array($uid)); if (empty($messages[$uid]) || !$messages[$uid]->exists(Horde_Imap_Client::FETCH_STRUCTURE)) { throw new Horde_ActiveSync_Exception('Message Gone'); } $msg = new Horde_ActiveSync_Imap_Message($imap, $mbox, $messages[$uid]); $part = $msg->getMimePart($part); return $part; }