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


PHP Horde_Mime_Headers类代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param string $from           The email address of the original sender.
  * @param Horde_Mime_Headers $h  The headers object for the message.
  */
 public function __construct($from, Horde_Mime_Headers $h)
 {
     global $prefs;
     $addressList = $nameList = array();
     /* First we'll get a comma separated list of email addresses
      * and a comma separated list of personal names out of $from
      * (there just might be more than one of each). */
     $addr_list = IMP::parseAddressList($from);
     foreach ($addr_list as $addr) {
         if (!is_null($addr->mailbox)) {
             $addressList[] = $addr->bare_address;
         }
         if (!is_null($addr->personal)) {
             $nameList[] = $addr->personal;
         } elseif (!is_null($addr->mailbox)) {
             $nameList[] = $addr->mailbox;
         }
     }
     /* Define the macros. */
     if (is_array($message_id = $h->getValue('message-id'))) {
         $message_id = reset($message_id);
     }
     if (!($subject = $h->getValue('subject'))) {
         $subject = _("[No Subject]");
     }
     $udate = strtotime($h->getValue('date'));
     $match = array('/%n/' => "\n", '/%%/' => '%', '/%f/' => $from, '/%a/' => implode(', ', $addressList), '/%p/' => implode(', ', $nameList), '/%r/' => $h->getValue('date'), '/%d/' => strftime("%a, %d %b %Y", $udate), '/%x/' => strftime("%x", $udate), '/%c/' => strftime("%c", $udate), '/%m/' => $message_id, '/%s/' => $subject);
     $this->_text = preg_replace(array_keys($match), array_values($match), $prefs->getValue('attrib_text'));
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:35,代码来源:AttribText.php

示例2: match

 /**
  * @param Horde_Mime_Headers $data
  */
 public function match($data)
 {
     if (!($ctype = $data->getValue('content-type', Horde_Mime_Headers::VALUE_BASE))) {
         return false;
     }
     @(list($primary, $sub) = explode('/', $ctype, 2));
     return $primary == 'multipart' && !in_array($sub, array('alternative', 'encrypt', 'related', 'signed'));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:11,代码来源:Attachment.php

示例3: __construct

 /**
  * Constructor.
  *
  * @param string|Horde_Mail_Rfc822_Object $from  The email address of the
  *                                               original sender.
  * @param Horde_Mime_Headers $h                  The headers object for
  *                                               the message.
  * @param string $attrib                         Use this for the
  *                                               attribution config
  *                                               instead of the default
  *                                               prefs version.
  */
 public function __construct($from, Horde_Mime_Headers $h, $attrib = null)
 {
     global $prefs;
     $this->_text = preg_replace_callback('/\\%./', function ($matches) use($from, $h) {
         switch ($matches[0]) {
             case '%n':
                 /* New line. */
                 return "\n";
             case '%%':
                 /* Percent character. */
                 return '%';
             case '%f':
                 /* Name and email address of original sender. */
                 if ($from) {
                     $from = new Horde_Mail_Rfc822_Address($from);
                     return $from->writeAddress(array('noquote' => true));
                 }
                 return _("Unknown Sender");
             case '%a':
                 /* Senders email address(es). */
             /* Senders email address(es). */
             case '%p':
                 /* Senders name(s). */
                 $out = array();
                 foreach (IMP::parseAddressList($from) as $addr) {
                     if ($matches[0] == '%a') {
                         if (!is_null($addr->mailbox)) {
                             $out[] = $addr->bare_address;
                         }
                     } else {
                         $out[] = $addr->label;
                     }
                 }
                 return count($out) ? implode(', ', $out) : _("Unknown Sender");
             case '%r':
                 /* RFC 822 date and time. */
                 return $h->getValue('date');
             case '%d':
                 /* Date as ddd, dd mmm yyyy. */
                 return strftime("%a, %d %b %Y", strtotime($h->getValue('date')));
             case '%c':
                 /* Date and time in locale's default. */
             /* Date and time in locale's default. */
             case '%x':
                 /* Date in locale's default. */
                 return strftime($matches[0], strtotime($h->getValue('date')));
             case '%m':
                 /* Message-ID. */
                 return is_array($message_id = $h->getValue('message-id')) ? reset($message_id) : $message_id;
             case '%s':
                 /* Message subject. */
                 return strlen($subject = $h->getValue('subject')) ? $subject : _("[No Subject]");
             default:
                 return '';
         }
     }, is_null($attrib) ? $prefs->getValue('attrib_text') : $attrib);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:69,代码来源:AttribText.php

示例4: testGenerate

    public function testGenerate()
    {
        $h = new Horde_Mime_Headers();
        $ob = new Horde_Mime_Mdn($h);
        try {
            $ob->generate(true, true, 'deleted', 'foo', null);
            $this->fail('Expected Exception');
        } catch (RuntimeException $e) {
        }
        $date = 'Tue, 18 Nov 2014 20:14:17 -0700';
        $mdn_addr = 'Aäb <foo@example.com>';
        $h->addHeader('Date', $date);
        $h->addHeader('Subject', 'Test');
        $h->addHeader('To', '"BAR" <bar@example.com>');
        $ob->addMdnRequestHeaders($mdn_addr);
        $mailer = new Horde_Mail_Transport_Mock();
        $ob->generate(true, true, 'displayed', 'test.example.com', $mailer, array('from_addr' => 'bar@example.com'), array('error'), array('error' => 'Foo'));
        $sent = str_replace("\r\n", "\n", $mailer->sentMessages[0]);
        $this->assertEquals('auto-replied', $sent['headers']['Auto-Submitted']);
        $this->assertEquals('bar@example.com', $sent['headers']['From']);
        $this->assertEquals($mdn_addr, Horde_Mime::decode($sent['headers']['To']));
        $this->assertEquals('Disposition Notification', $sent['headers']['Subject']);
        $this->assertStringMatchesFormat('This message is in MIME format.

--=%s
Content-Type: text/plain; format=flowed; DelSp=Yes

The message sent on Tue, 18 Nov 2014 20:14:17 -0700 to BAR  
<bar@example.com> with subject "Test" has been displayed.

This is no guarantee that the message has been read or understood.

--=%s
Content-Type: message/disposition-notification

Reporting-UA: test.example.com; Horde Application Framework 5
Final-Recipient: rfc822;bar@example.com
Disposition: manual-action/MDN-sent-manually; displayed/error
Error: Foo

--=%s
Content-Type: message/rfc822

Date: Tue, 18 Nov 2014 20:14:17 -0700
Subject: Test
To: BAR <bar@example.com>
Disposition-Notification-To: =?utf-8?b?QcOkYg==?= <foo@example.com>

--=%s
', $sent['body']);
    }
开发者ID:raz0rsdge,项目名称:horde,代码行数:51,代码来源:NonTranslatedTest.php

示例5: verifyIdentity

 /**
  * Sends a message to an email address supposed to be added to the
  * identity.
  *
  * A message is send to this address containing a time-sensitive link to
  * confirm that the address really belongs to that user.
  *
  * @param integer $id       The identity's ID.
  * @param string $old_addr  The old From: address.
  *
  * @throws Horde_Mime_Exception
  */
 public function verifyIdentity($id, $old_addr)
 {
     global $injector, $notification, $registry;
     $hash = strval(new Horde_Support_Randomid());
     $pref = $this->_confirmEmail();
     $pref[$hash] = $this->get($id);
     $pref[$hash][self::EXPIRE] = time() + self::EXPIRE_SECS;
     $this->_confirmEmail($pref);
     $new_addr = $this->getValue($this->_prefnames['from_addr'], $id);
     $confirm = Horde::url($registry->getServiceLink('emailconfirm')->add('h', $hash)->setRaw(true), true);
     $message = sprintf(Horde_Core_Translation::t("You have requested to add the email address \"%s\" to the list of your personal email addresses.\n\nGo to the following link to confirm that this is really your address:\n%s\n\nIf you don't know what this message means, you can delete it."), $new_addr, $confirm);
     $msg_headers = new Horde_Mime_Headers();
     $msg_headers->addHeaderOb(Horde_Mime_Headers_MessageId::create());
     $msg_headers->addHeaderOb(Horde_Mime_Headers_UserAgent::create());
     $msg_headers->addHeaderOb(Horde_Mime_Headers_Date::create());
     $msg_headers->addHeader('To', $new_addr);
     $msg_headers->addHeader('From', $old_addr);
     $msg_headers->addHeader('Subject', Horde_Core_Translation::t("Confirm new email address"));
     $body = new Horde_Mime_Part();
     $body->setType('text/plain');
     $body->setContents(Horde_String::wrap($message, 76));
     $body->setCharset('UTF-8');
     $body->send($new_addr, $msg_headers, $injector->getInstance('Horde_Mail'));
     $notification->push(sprintf(Horde_Core_Translation::t("A message has been sent to \"%s\" to verify that this is really your address. The new email address is activated as soon as you confirm this message."), $new_addr), 'horde.message');
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:37,代码来源:Identity.php

示例6: _renderInfo

 /**
  * Return the rendered information about the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _renderInfo()
 {
     global $registry;
     if ($registry->getView() == $registry::VIEW_MINIMAL) {
         return array();
     }
     $status = array();
     $mime_id = $this->_mimepart->getMimeId();
     $headers = Horde_Mime_Headers::parseHeaders($this->getConfigParam('imp_contents')->getBodyPart($mime_id, array('length' => 0, 'mimeheaders' => true, 'stream' => true))->data);
     if (($duration = $headers->getValue('content-duration')) !== null) {
         $text = array();
         if ($minutes = floor($duration / 60)) {
             $text[] = sprintf(ngettext(_("%d minute"), _("%d minutes"), $minutes), $minutes);
         }
         if ($seconds = $duration % 60) {
             $text[] = sprintf(ngettext(_("%d second"), _("%d seconds"), $seconds), $seconds);
         }
         $status[] = sprintf(_("This video file is reported to be %s in length."), implode(' ', $text));
     }
     if ($this->_thumbnailBinary()) {
         $status[] = _("This is a thumbnail of a video attachment.");
         $status[] = $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', '<img src="' . $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'view_attach', array('params' => array('imp_video_view' => 'view_thumbnail'))) . '" />', null, null, null);
     }
     if (empty($status)) {
         return array();
     }
     $s = new IMP_Mime_Status($status);
     $s->icon('mime/video.png');
     return array($this->_mimepart->getMimeId() => array('data' => '', 'status' => $s, 'type' => 'text/html; charset=UTF-8'));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:35,代码来源:Video.php

示例7: __construct

 /**
  * Cont'r
  *
  * @param array $params  Parameters:
  *   - factory: (Horde_ActiveSync_Interface_ImapFactory) Factory object
  *              DEFAULT: none - REQUIRED
  */
 public function __construct(array $params = array())
 {
     $this->_imap = $params['factory'];
     Horde_Mime_Part::$defaultCharset = 'UTF-8';
     Horde_Mime_Headers::$defaultCharset = 'UTF-8';
     $this->_procid = getmypid();
     $this->_logger = new Horde_Log_Logger(new Horde_Log_Handler_Null());
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:15,代码来源:Adapter.php

示例8: getPriority

 /**
  * Determines the priority of the message based on the headers.
  *
  * @param Horde_Mime_Headers $header  The headers object.
  *
  * @return string  'high', 'low', or 'normal'.
  */
 public function getPriority($header)
 {
     if (($xpriority = $header->getValue('x-priority')) && preg_match('/\\s*(\\d+)\\s*/', $xpriority, $matches)) {
         if (in_array($matches[1], array(1, 2))) {
             return 'high';
         } elseif (in_array($matches[1], array(4, 5))) {
             return 'low';
         }
     } elseif (($importance = $header->getValue('importance')) && preg_match('/:\\s*(\\w+)\\s*/', $importance, $matches)) {
         if (strcasecmp($matches[1], 'high') === 0) {
             return 'high';
         } elseif (strcasecmp($matches[1], 'low') === 0) {
             return 'low';
         }
     }
     return 'normal';
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:24,代码来源:Headers.php

示例9: testMIMEEncodingWhenStandardHeadersAreAdded

 /**
  * See Bug #13456  Wnen we add the Message-Id/User-Agent headers, make sure
  * we don't cause the subject header to not be MIME encoded.
  */
 public function testMIMEEncodingWhenStandardHeadersAreAdded()
 {
     $fixture = file_get_contents(__DIR__ . '/fixtures/mime_encoding.eml');
     $rfc822 = new Horde_ActiveSync_Rfc822($fixture, true);
     $hdrs = Horde_Mime_Headers::parseHeaders($rfc822->getString());
     $hdr_array = $hdrs->toArray(array('charset' => 'UTF-8'));
     $this->assertEquals('=?utf-8?b?w4PDhMOjw6s=?=', $hdr_array['Subject']);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:12,代码来源:Rfc822Test.php

示例10: loadFixtures

 /**
  * TODO
  */
 public function loadFixtures($dir)
 {
     $this->_fixtures = array();
     $dh = opendir($dir);
     while (($dent = readdir($dh)) !== false) {
         if (!in_array($dent, array('.', '..'))) {
             $this->_fixtures[$dent] = Horde_Mime_Headers::parseHeaders(file_get_contents($dir . '/' . $dent));
         }
     }
     closedir($dh);
     $i = 0;
     foreach (array_keys($this->_fixtures) as $key) {
         $this->_folders['INBOX'][] = array('uid' => ++$i, 'fixture' => $key, 'deleted' => false);
     }
 }
开发者ID:horde,项目名称:horde,代码行数:18,代码来源:Mock.php

示例11: _renderInfo

 /**
  * Return the rendered information about the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _renderInfo()
 {
     $mime_id = $this->_mimepart->getMimeId();
     $headers = Horde_Mime_Headers::parseHeaders($this->getConfigParam('imp_contents')->getBodyPart($mime_id, array('length' => 0, 'mimeheaders' => true, 'stream' => true))->data);
     if (($duration = $headers->getValue('content-duration')) === null) {
         return array();
     }
     $text = array();
     if ($minutes = floor($duration / 60)) {
         $text[] = sprintf(ngettext(_("%d minute"), _("%d minutes"), $minutes), $minutes);
     }
     if ($seconds = $duration % 60) {
         $text[] = sprintf(ngettext(_("%d second"), _("%d seconds"), $seconds), $seconds);
     }
     $status = new IMP_Mime_Status(sprintf(_("This audio file is reported to be %s in length."), implode(' ', $text)));
     $status->icon('mime/audio.png');
     return array($this->_mimepart->getMimeId() => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8'));
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:23,代码来源:Audio.php

示例12: report

 /**
  */
 public function report(IMP_Contents $contents, $action)
 {
     global $injector, $registry;
     $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create();
     switch ($this->_format) {
         case 'redirect':
             /* Send the message. */
             try {
                 $imp_compose->redirectMessage($contents->getIndicesOb());
                 $imp_compose->sendRedirectMessage($this->_email, false);
                 return true;
             } catch (IMP_Compose_Exception $e) {
                 $e->log();
             }
             break;
         case 'digest':
         default:
             try {
                 $from_line = $injector->getInstance('IMP_Identity')->getFromLine();
             } catch (Horde_Exception $e) {
                 $from_line = null;
             }
             /* Build the MIME structure. */
             $mime = new Horde_Mime_Part();
             $mime->setType('multipart/digest');
             $rfc822 = new Horde_Mime_Part();
             $rfc822->setType('message/rfc822');
             $rfc822->setContents($contents->fullMessageText(array('stream' => true)));
             $mime->addPart($rfc822);
             $spam_headers = new Horde_Mime_Headers();
             $spam_headers->addMessageIdHeader();
             $spam_headers->addHeader('Date', date('r'));
             $spam_headers->addHeader('To', $this->_email);
             if (!is_null($from_line)) {
                 $spam_headers->addHeader('From', $from_line);
             }
             $spam_headers->addHeader('Subject', sprintf(_("%s report from %s"), $action == IMP_Spam::SPAM ? 'spam' : 'innocent', $registry->getAuth()));
             /* Send the message. */
             try {
                 $recip_list = $imp_compose->recipientList(array('to' => $this->_email));
                 $imp_compose->sendMessage($recip_list['list'], $spam_headers, $mime, 'UTF-8');
                 $rfc822->clearContents();
                 return true;
             } catch (IMP_Compose_Exception $e) {
                 $e->log();
                 $rfc822->clearContents();
             }
             break;
     }
     return false;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:53,代码来源:Email.php

示例13: userConfirmationNeededProvider

 public function userConfirmationNeededProvider()
 {
     $out = array();
     $h = new Horde_Mime_Headers();
     $out[] = array(clone $h, true);
     $h->addHeader('Return-Path', 'foo@example.com');
     $out[] = array(clone $h, false);
     $h->addHeader('Return-Path', 'foo2@example.com');
     $out[] = array(clone $h, true);
     $h->replaceHeader('Return-Path', 'foo@example.com');
     $h->addHeader(Horde_Mime_Mdn::MDN_HEADER, 'FOO@example.com');
     $out[] = array(clone $h, true);
     $h->replaceHeader(Horde_Mime_Mdn::MDN_HEADER, 'foo@EXAMPLE.com');
     $out[] = array(clone $h, false);
     return $out;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:16,代码来源:MdnTest.php

示例14: _pop3Cache

 /**
  * Retrieve locally cached message data.
  *
  * @param string $type    Either 'hdr', 'hdrob', 'msg', 'size', 'stat',
  *                        or 'uidl'.
  * @param integer $index  The message index.
  * @param mixed $data     Additional information needed.
  *
  * @return mixed  The cached data. 'msg' returns a stream resource. All
  *                other types return strings.
  *
  * @throws Horde_Imap_Client_Exception
  */
 protected function _pop3Cache($type, $index = null, $data = null)
 {
     if (isset($this->_temp['pop3cache'][$index][$type])) {
         if ($type == 'msg') {
             rewind($this->_temp['pop3cache'][$index][$type]);
         }
         return $this->_temp['pop3cache'][$index][$type];
     }
     switch ($type) {
         case 'hdr':
             $data = null;
             if ($this->queryCapability('TOP')) {
                 try {
                     $resp = $this->_sendLine('TOP ' . $index . ' 0');
                     $ptr = $this->_getMultiline();
                     rewind($ptr);
                     $data = stream_get_contents($ptr);
                     fclose($ptr);
                 } catch (Horde_Imap_Client_Exception $e) {
                 }
             }
             if (is_null($data)) {
                 $data = Horde_Mime_Part::getRawPartText(stream_get_contents($this->_pop3Cache('msg', $index)), 'header', 0);
             }
             break;
         case 'hdrob':
             $data = Horde_Mime_Headers::parseHeaders($this->_pop3Cache('hdr', $index));
             break;
         case 'msg':
             $resp = $this->_sendLine('RETR ' . $index);
             $data = $this->_getMultiline();
             rewind($data);
             break;
         case 'size':
         case 'uidl':
             $data = array();
             try {
                 $this->_sendLine($type == 'size' ? 'LIST' : 'UIDL');
                 foreach ($this->_getMultiline(true) as $val) {
                     $resp_data = explode(' ', $val, 2);
                     $data[$resp_data[0]] = $resp_data[1];
                 }
             } catch (Horde_Imap_Client_Exception $e) {
             }
             break;
         case 'stat':
             $resp = $this->_sendLine('STAT');
             $resp_data = explode(' ', $resp['line'], 2);
             $data = array('msgs' => $resp_data[0], 'size' => $resp_data[1]);
             break;
     }
     $this->_temp['pop3cache'][$index][$type] = $data;
     return $data;
 }
开发者ID:netcon-source,项目名称:apps,代码行数:67,代码来源:Pop3.php

示例15: parseHeaders

 /**
  * Builds a Horde_Mime_Headers object from header text.
  * This function can be called statically:
  *   $headers = Horde_Mime_Headers::parseHeaders().
  *
  * @param string $text  A text string containing the headers.
  *
  * @return Horde_Mime_Headers  A new Horde_Mime_Headers object.
  */
 public static function parseHeaders($text)
 {
     $currheader = $currtext = null;
     $mime = self::mimeParamFields();
     $to_process = array();
     foreach (explode("\n", $text) as $val) {
         $val = rtrim($val);
         if (empty($val)) {
             break;
         }
         if ($val[0] == ' ' || $val[0] == "\t") {
             $currtext .= ' ' . ltrim($val);
         } else {
             if (!is_null($currheader)) {
                 $to_process[] = array($currheader, $currtext);
             }
             $pos = strpos($val, ':');
             $currheader = substr($val, 0, $pos);
             $currtext = ltrim(substr($val, $pos + 1));
         }
     }
     if (!is_null($currheader)) {
         $to_process[] = array($currheader, $currtext);
     }
     $headers = new Horde_Mime_Headers();
     reset($to_process);
     while (list(, $val) = each($to_process)) {
         /* Ignore empty headers. */
         if (!strlen($val[1])) {
             continue;
         }
         if (in_array(Horde_String::lower($val[0]), $mime)) {
             $res = Horde_Mime::decodeParam($val[0], $val[1]);
             $headers->addHeader($val[0], $res['val'], array('params' => $res['params'], 'sanity_check' => true));
         } else {
             $headers->addHeader($val[0], $val[1], array('sanity_check' => true));
         }
     }
     return $headers;
 }
开发者ID:netcon-source,项目名称:apps,代码行数:49,代码来源:Headers.php


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