IMP_Compose::_saveDraftMsg PHP 메소드

_saveDraftMsg() 보호된 메소드

Prepare the draft message.
protected _saveDraftMsg ( array $headers, mixed $message, array $opts ) : string
$headers array List of message headers.
$message mixed Either the message text (string) or a Horde_Mime_Part object that contains the text to send.
$opts array An array of options w/the following keys: - html: (boolean) Is this an HTML message? - priority: (string) The message priority ('high', 'normal', 'low'). - readreceipt: (boolean) Add return receipt headers? - verify_email: (boolean) Verify e-mail messages? Default: no.
리턴 string The body text.
    protected function _saveDraftMsg($headers, $message, $opts)
    {
        global $injector, $registry;
        $has_session = (bool) $registry->getAuth();
        /* Set up the base message now. */
        $base = $this->_createMimeMessage($message, array('html' => !empty($opts['html']), 'noattach' => !$has_session, 'nofinal' => true));
        $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
        $recip_list = $this->recipientList($headers);
        if (!empty($opts['verify_email'])) {
            foreach ($recip_list['list'] as $val) {
                try {
                    /* For draft messages, the key is whether the IMAP server
                     * supports EAI addresses. */
                    $utf8 = $imp_imap->client_ob->capability->query('UTF8', 'ACCEPT');
                    IMP::parseAddressList($val->writeAddress(true), array('validate' => $utf8 ? 'eai' : true));
                } catch (Horde_Mail_Exception $e) {
                    throw new IMP_Compose_Exception(sprintf(_("Saving the message failed because it contains an invalid e-mail address: %s."), strval($val), $e->getMessage()), $e->getCode());
                }
            }
        }
        $headers = array_merge($headers, $recip_list['header']);
        /* Initalize a header object for the draft. */
        $draft_headers = $this->_prepareHeaders($headers, $opts);
        /* Add information necessary to log replies/forwards when finally
         * sent. */
        if ($this->_replytype) {
            try {
                $indices = $this->getMetadata('indices');
                $imap_url = new Horde_Imap_Client_Url();
                $imap_url->hostspec = $imp_imap->getParam('hostspec');
                $imap_url->protocol = $imp_imap->isImap() ? 'imap' : 'pop';
                $imap_url->username = $imp_imap->getParam('username');
                $urls = array();
                foreach ($indices as $val) {
                    $imap_url->mailbox = $val->mbox;
                    $imap_url->uidvalidity = $val->mbox->uidvalid;
                    foreach ($val->uids as $val2) {
                        $imap_url->uid = $val2;
                        $urls[] = '<' . strval($imap_url) . '>';
                    }
                }
                switch ($this->replyType(true)) {
                    case self::FORWARD:
                        $draft_headers->addHeader(self::DRAFT_FWD, implode(', ', $urls));
                        break;
                    case self::REPLY:
                        $draft_headers->addHeader(self::DRAFT_REPLY, implode(', ', $urls));
                        $draft_headers->addHeader(self::DRAFT_REPLY_TYPE, $this->_replytype);
                        break;
                }
            } catch (Horde_Exception $e) {
            }
        } else {
            $draft_headers->addHeader(self::DRAFT_HDR, 'Yes');
        }
        return $base->toString(array('defserver' => $has_session ? $imp_imap->config->maildomain : null, 'headers' => $draft_headers));
    }