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


PHP Horde_Mime_Headers::addHeader方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: addHeader

 /**
  * Adds a message header.
  *
  * @param string $header      The header name.
  * @param string $value       The header value.
  * @param boolean $overwrite  If true, an existing header of the same name
  *                            is being overwritten; if false, multiple
  *                            headers are added; if null, the correct
  *                            behaviour is automatically chosen depending
  *                            on the header name.
  *
  * @throws Horde_Mime_Exception
  */
 public function addHeader($header, $value, $overwrite = null)
 {
     $lc_header = Horde_String::lower($header);
     if (is_null($overwrite) && in_array($lc_header, $this->_headers->singleFields(true))) {
         $overwrite = true;
     }
     if ($overwrite) {
         $this->_headers->removeHeader($header);
     }
     if ($lc_header === 'bcc') {
         $this->_bcc = $value;
     } else {
         $this->_headers->addHeader($header, $value);
     }
 }
开发者ID:x59,项目名称:horde-mime,代码行数:28,代码来源:Mail.php

示例6: __set

 /**
  */
 public function __set($name, $value)
 {
     if (!strlen($value)) {
         return;
     }
     switch ($name) {
         case 'bcc':
         case 'cc':
         case 'date':
         case 'from':
         case 'in_reply_to':
         case 'message_id':
         case 'reply_to':
         case 'sender':
         case 'subject':
         case 'to':
             switch ($name) {
                 case 'from':
                     foreach (array('reply_to', 'sender') as $val) {
                         if ($this->{$val}->match($value)) {
                             $this->_data->removeHeader($val);
                         }
                     }
                     break;
                 case 'reply_to':
                 case 'sender':
                     if ($this->from->match($value)) {
                         $this->_data->removeHeader($name);
                         return;
                     }
                     /* Convert reply-to name. */
                     if ($name == 'reply_to') {
                         $name = 'reply-to';
                     }
                     break;
             }
             $this->_data->addHeader($name, $value, array('sanity_check' => true));
             break;
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:42,代码来源:Envelope.php

示例7: __set

 /**
  */
 public function __set($name, $value)
 {
     if (!strlen($value)) {
         return;
     }
     $name = $this->_normalizeProperty($name);
     switch ($name) {
         case 'bcc':
         case 'cc':
         case 'date':
         case 'from':
         case 'in-reply-to':
         case 'message-id':
         case 'reply-to':
         case 'sender':
         case 'subject':
         case 'to':
             switch ($name) {
                 case 'from':
                     if ($this->reply_to->match($value)) {
                         unset($this->_data['reply-to']);
                     }
                     if ($this->sender->match($value)) {
                         unset($this->_data['sender']);
                     }
                     break;
                 case 'reply-to':
                 case 'sender':
                     if ($this->from->match($value)) {
                         unset($this->_data[$name]);
                         return;
                     }
                     break;
             }
             $this->_data->addHeader($name, $value);
             break;
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:40,代码来源:Envelope.php

示例8: testUndisclosedHeaderParsing

 public function testUndisclosedHeaderParsing()
 {
     $hdrs = new Horde_Mime_Headers();
     $hdrs->addHeader('To', 'undisclosed-recipients');
     $this->assertEquals('', $hdrs->getValue('To'));
     $hdrs = new Horde_Mime_Headers();
     $hdrs->addHeader('To', 'undisclosed-recipients:');
     $this->assertEquals('', $hdrs->getValue('To'));
     $hdrs = new Horde_Mime_Headers();
     $hdrs->addHeader('To', 'undisclosed-recipients:;');
     $this->assertEquals('', $hdrs->getValue('To'));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:12,代码来源:HeadersTest.php

示例9: parseHeaders

 /**
  * Builds a Horde_Mime_Headers object from header text.
  *
  * @param mixed $text  A text string (or, as of 2.3.0, a Horde_Stream
  *                     object or stream resource) containing the headers.
  *
  * @return Horde_Mime_Headers  A new Horde_Mime_Headers object.
  */
 public static function parseHeaders($text)
 {
     $curr = null;
     $headers = new Horde_Mime_Headers();
     $hdr_list = array();
     if ($text instanceof Horde_Stream) {
         $stream = $text;
         $stream->rewind();
     } else {
         $stream = new Horde_Stream_Temp();
         $stream->add($text, true);
     }
     while (!$stream->eof()) {
         if (!($val = rtrim($stream->getToChar("\n", false), "\r"))) {
             break;
         }
         if ($curr && ($val[0] == ' ' || $val[0] == "\t")) {
             $curr->text .= ' ' . ltrim($val);
         } else {
             $pos = strpos($val, ':');
             $curr = new stdClass();
             $curr->header = substr($val, 0, $pos);
             $curr->text = ltrim(substr($val, $pos + 1));
             $hdr_list[] = $curr;
         }
     }
     foreach ($hdr_list as $val) {
         /* When parsing, only keep the FIRST header seen for single value
          * text-only headers, since newer headers generally are appended
          * to the top of the message. */
         if (!($ob = $headers[$val->header]) || !$ob instanceof Horde_Mime_Headers_Element_Single || $ob instanceof Horde_Mime_Headers_Addresses) {
             $headers->addHeader($val->header, rtrim($val->text));
         }
     }
     if (!$text instanceof Horde_Stream) {
         $stream->close();
     }
     return $headers;
 }
开发者ID:x59,项目名称:horde-mime,代码行数:47,代码来源:Headers.php

示例10: createEnvelopeHeaders

 /**
  * Generate the headers for the MIME envelope of a Kolab groupware object.
  *
  * @param string $user The current user.
  *
  * @return Horde_Mime_Headers The headers for the MIME envelope.
  */
 protected function createEnvelopeHeaders()
 {
     $headers = new Horde_Mime_Headers();
     $headers->setEOL("\r\n");
     $headers->addHeader('From', $this->_getDriver()->getAuth());
     $headers->addHeader('To', $this->_getDriver()->getAuth());
     $headers->addHeader('Date', date('r'));
     $headers->addHeader('Subject', $this->getUid());
     $headers->addHeader('User-Agent', 'Horde_Kolab_Storage ' . Horde_Kolab_Storage::VERSION);
     $headers->addHeader('MIME-Version', '1.0');
     $headers->addHeader('X-Kolab-Type', Horde_Kolab_Storage_Object_MimeType::getMimeTypeFromObjectType($this->getType()));
     return $headers;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:20,代码来源:Object.php

示例11: sendNotification

 /**
  * Send notification to attachment owner.
  */
 public function sendNotification()
 {
     global $conf, $injector, $registry;
     if (empty($conf['compose']['link_attachments_notify'])) {
         return;
     }
     try {
         $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create($this->_user);
         $address = $identity->getDefaultFromAddress();
         /* Ignore missing addresses, which are returned as <>. */
         if (strlen($address) < 3 || $this->_getDeleteToken()) {
             return;
         }
         $address_full = $identity->getDefaultFromAddress(true);
         /* Load user prefs to correctly translate gettext strings. */
         if (!$registry->getAuth()) {
             $prefs = $injector->getInstance('Horde_Core_Factory_Prefs')->create('imp', array('user' => $this->_user));
             $registry->setLanguageEnvironment($prefs->getValue('language'));
         }
         $h = new Horde_Mime_Headers();
         $h->addReceivedHeader(array('dns' => $injector->getInstance('Net_DNS2_Resolver'), 'server' => $conf['server']['name']));
         $h->addMessageIdHeader();
         $h->addUserAgentHeader();
         $h->addHeader('Date', date('r'));
         $h->addHeader('From', $address_full);
         $h->addHeader('To', $address_full);
         $h->addHeader('Subject', _("Notification: Linked attachment downloaded"));
         $h->addHeader('Auto-Submitted', 'auto-generated');
         $msg = new Horde_Mime_Part();
         $msg->setType('text/plain');
         $msg->setCharset('UTF-8');
         $md = $this->_atc->getMetadata();
         $msg->setContents(Horde_String::wrap(_("Your linked attachment has been downloaded by at least one user.") . "\n\n" . sprintf(_("Name: %s"), $md->filename) . "\n" . sprintf(_("Type: %s"), $md->type) . "\n" . sprintf(_("Sent Date: %s"), date('r', $md->time)) . "\n\n" . _("Click on the following link to permanently delete the attachment:") . "\n" . strval($this->_atc->link_url->add('d', $this->_getDeleteToken(true)))));
         $msg->send($address, $h, $injector->getInstance('Horde_Mail'));
     } catch (Exception $e) {
         Horde::log($e, 'ERR');
     }
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:41,代码来源:LinkedAttachment.php

示例12: testHeaderGeneration

 /**
  * @dataProvider headerGenerationProvider
  */
 public function testHeaderGeneration($label, $data, $class)
 {
     $hdrs = new Horde_Mime_Headers();
     $this->assertNull($hdrs[$label]);
     $hdrs->addHeader($label, $data);
     $ob = $hdrs[$label];
     $this->assertNotNull($ob);
     $this->assertInstanceOf($class, $ob);
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:12,代码来源:HeadersTest.php

示例13: draftToMime

 /**
  * Get a Horde_Mime object representint the data contained in this object.
  *
  * [MS_ASEMAIL 3.1.53]
  *
  * @return array An array containing:
  *         - part: Horde_Mime_Part containing the body data NO ATTACHMENTS.
  *         - headers: Horde_Mime_Headers containing the envelope headers.
  */
 public function draftToMime()
 {
     // Main text body.
     $text = new Horde_Mime_Part();
     $body = $this->airsyncbasebody;
     $text->setContents($body->data);
     if ($body->type == Horde_ActiveSync::BODYPREF_TYPE_HTML) {
         $text->setType('text/html');
     } else {
         $text->setType('text/plain');
     }
     // Add headers that are sent with ADD;
     $headers = new Horde_Mime_Headers();
     if ($this->to) {
         $headers->addHeader('To', $this->to);
     }
     if ($this->cc) {
         $headers->addHeader('Cc', $this->cc);
     }
     if ($this->subject) {
         $headers->addHeader('Subject', $this->subject);
     }
     if ($this->bcc) {
         $headers->addHeader('Bcc', $this->bcc);
     }
     if ($this->reply_to) {
         $headers->addHeader('reply-to', $this->reply_to);
     }
     if ($this->importance) {
         $headers->addHeader('importance', $this->importance);
     }
     return array('part' => $text, 'headers' => $headers);
 }
开发者ID:horde,项目名称:horde,代码行数:42,代码来源:Mail.php

示例14: sendRedirectMessage

 /**
  * Send a redirect (a/k/a resent) message. See RFC 5322 [3.6.6].
  *
  * @param mixed $to  The addresses to redirect to.
  * @param boolean $log  Whether to log the resending in the history and
  *                      sentmail log.
  *
  * @return array  An object with the following properties for each
  *                redirected message:
  *   - contents: (IMP_Contents) The contents object.
  *   - headers: (Horde_Mime_Headers) The header object.
  *   - mbox: (IMP_Mailbox) Mailbox of the message.
  *   - uid: (string) UID of the message.
  *
  * @throws IMP_Compose_Exception
  */
 public function sendRedirectMessage($to, $log = true)
 {
     global $injector, $registry;
     $recip = $this->recipientList(array('to' => $to));
     $identity = $injector->getInstance('IMP_Identity');
     $from_addr = $identity->getFromAddress();
     $out = array();
     foreach ($this->getMetadata('redirect_indices') as $val) {
         foreach ($val->uids as $val2) {
             try {
                 $contents = $injector->getInstance('IMP_Factory_Contents')->create($val->mbox->getIndicesOb($val2));
             } catch (IMP_Exception $e) {
                 throw new IMP_Compose_Exception(_("Error when redirecting message."));
             }
             $headers = $contents->getHeader();
             /* We need to set the Return-Path header to the current user -
              * see RFC 2821 [4.4]. */
             $headers->removeHeader('return-path');
             $headers->addHeader('Return-Path', $from_addr);
             /* Generate the 'Resent' headers (RFC 5322 [3.6.6]). These
              * headers are prepended to the message. */
             $resent_headers = new Horde_Mime_Headers();
             $resent_headers->addHeader('Resent-Date', date('r'));
             $resent_headers->addHeader('Resent-From', $from_addr);
             $resent_headers->addHeader('Resent-To', $recip['header']['to']);
             $resent_headers->addHeader('Resent-Message-ID', Horde_Mime_Headers_MessageId::create());
             $header_text = trim($resent_headers->toString(array('encode' => 'UTF-8'))) . "\n" . trim($contents->getHeader(IMP_Contents::HEADER_TEXT));
             $this->_prepSendMessageAssert($recip['list']);
             $to = $this->_prepSendMessage($recip['list']);
             $hdr_array = $headers->toArray(array('charset' => 'UTF-8'));
             $hdr_array['_raw'] = $header_text;
             try {
                 $injector->getInstance('IMP_Mail')->send($to, $hdr_array, $contents->getBody());
             } catch (Horde_Mail_Exception $e) {
                 $e2 = new IMP_Compose_Exception($e);
                 if (($prev = $e->getPrevious()) && $prev instanceof Horde_Smtp_Exception) {
                     if ($prev instanceof Horde_Smtp_Exception_Recipients) {
                         $e2 = new IMP_Compose_Exception_Addresses($e);
                         foreach ($prev->recipients as $val) {
                             $e2->addAddress(new Horde_Mail_Rfc822_Address($val), _("Address rejected by the sending mail server."), $e2::BAD);
                         }
                     }
                     Horde::log(sprintf("SMTP Error: %s (%u; %s)", $prev->raw_msg, $prev->getCode(), $prev->getEnhancedSmtpCode() ?: 'N/A'), 'ERR');
                     $e2->logged = true;
                 }
                 throw $e2;
             }
             $recipients = strval($recip['list']);
             Horde::log(sprintf("%s Redirected message sent to %s from %s", $_SERVER['REMOTE_ADDR'], $recipients, $registry->getAuth()), 'INFO');
             if ($log && ($tmp = $headers['Message-ID'])) {
                 $msg_id = reset($tmp->getIdentificationOb()->ids);
                 /* Store history information. */
                 $injector->getInstance('IMP_Maillog')->log(new IMP_Maillog_Message($msg_id), new IMP_Maillog_Log_Redirect(array('msgid' => reset($resent_headers->getIdentificationOb()->ids), 'recipients' => $recipients)));
                 $injector->getInstance('IMP_Sentmail')->log(IMP_Sentmail::REDIRECT, $msg_id, $recipients);
             }
             $tmp = new stdClass();
             $tmp->contents = $contents;
             $tmp->headers = $headers;
             $tmp->mbox = $val->mbox;
             $tmp->uid = $val2;
             $out[] = $tmp;
         }
     }
     return $out;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:81,代码来源:Compose.php

示例15: testMatchMimePartToHeaderType

 /**
  * @dataProvider getObjectAndMimeTypes
  */
 public function testMatchMimePartToHeaderType($type, $mime_type)
 {
     $headers = new Horde_Mime_Headers();
     $headers->addHeader('X-Kolab-Type', $mime_type);
     $this->assertEquals(array(2, $type), Horde_Kolab_Storage_Object_MimeType::matchMimePartToHeaderType($this->getMultipartMimeMessage($mime_type), $headers));
 }
开发者ID:horde,项目名称:horde,代码行数:9,代码来源:MimeTypeTest.php


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