本文整理汇总了PHP中Horde_Imap_Client_Fetch_Query::bodyText方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Imap_Client_Fetch_Query::bodyText方法的具体用法?PHP Horde_Imap_Client_Fetch_Query::bodyText怎么用?PHP Horde_Imap_Client_Fetch_Query::bodyText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Imap_Client_Fetch_Query
的用法示例。
在下文中一共展示了Horde_Imap_Client_Fetch_Query::bodyText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generates a string that can be saved out to an mbox format mailbox file
* for a mailbox (or set of mailboxes), optionally including all
* subfolders of the selected mailbox(es) as well. All mailboxes will be
* output in the same string.
*
* @param mixed $mboxes A mailbox name (UTF-8), or list of mailbox names,
* to generate a mbox file for.
*
* @return resource A stream resource containing the text of a mbox
* format mailbox file.
*/
public function generate($mboxes)
{
$body = fopen('php://temp', 'r+');
if (!is_array($mboxes)) {
if (!strlen($mboxes)) {
return $body;
}
$mboxes = array($mboxes);
}
if (empty($mboxes)) {
return $body;
}
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$query->imapDate();
$query->headerText(array('peek' => true));
$query->bodyText(array('peek' => true));
foreach (IMP_Mailbox::get($mboxes) as $val) {
$imp_imap = $val->imp_imap;
$slices = $imp_imap->getSlices($val, $imp_imap->getIdsOb(Horde_Imap_Client_Ids::ALL, true));
foreach ($slices as $slice) {
try {
$res = $imp_imap->fetch($val, $query, array('ids' => $slice, 'nocache' => true));
} catch (IMP_Imap_Exception $e) {
continue;
}
foreach ($res as $ptr) {
$from_env = $ptr->getEnvelope()->from;
$from = count($from_env) ? $from_env[0]->bare_address : '<>';
/* We need this long command since some MUAs (e.g. pine)
* require a space in front of single digit days. */
$imap_date = $ptr->getImapDate();
$date = sprintf('%s %2s %s', $imap_date->format('D M'), $imap_date->format('j'), $imap_date->format('H:i:s Y'));
fwrite($body, 'From ' . $from . ' ' . $date . "\r\n");
/* Remove spurious 'From ' line in headers. */
$stream = $ptr->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_STREAM);
while (!feof($stream)) {
$line = fgets($stream);
if (substr($line, 0, 5) != 'From ') {
fwrite($body, $line);
}
}
fwrite($body, "\r\n");
/* Add Body text. */
$stream = $ptr->getBodyText(0, true);
while (!feof($stream)) {
fwrite($body, fread($stream, 8192));
}
fwrite($body, "\r\n");
}
}
}
return $body;
}
示例2: fetchFromUrl
/**
* Given an IMAP URL, fetches the corresponding part.
*
* @param Horde_Imap_Client_Url $url An IMAP URL.
*
* @return resource The section contents in a stream. Returns null if
* the part could not be found.
*
* @throws Horde_Imap_Client_Exception
*/
public function fetchFromUrl(Horde_Imap_Client_Url $url)
{
$ids_ob = $this->_socket->getIdsOb($url->uid);
// BODY[]
if (is_null($section)) {
$query = new Horde_Imap_Client_Fetch_Query();
$query->fullText(array('peek' => true));
$fetch = $this->_socket->fetch($url->mailbox, $query, array('ids' => $ids_ob));
return $fetch[$url->uid]->getFullMsg(true);
}
$section = trim($url->section);
// BODY[<#.>HEADER.FIELDS<.NOT>()]
if (($pos = stripos($section, 'HEADER.FIELDS')) !== false) {
$hdr_pos = strpos($section, '(');
$cmd = substr($section, 0, $hdr_pos);
$query = new Horde_Imap_Client_Fetch_Query();
$query->headers('section', explode(' ', substr($section, $hdr_pos + 1, strrpos($section, ')') - $hdr_pos)), array('id' => $pos ? substr($section, 0, $pos - 1) : 0, 'notsearch' => stripos($cmd, '.NOT') !== false, 'peek' => true));
$fetch = $this->_socket->fetch($url->mailbox, $query, array('ids' => $ids_ob));
return $fetch[$url->uid]->getHeaders('section', Horde_Imap_Client_Data_Fetch::HEADER_STREAM);
}
// BODY[#]
if (is_numeric(substr($section, -1))) {
$query = new Horde_Imap_Client_Fetch_Query();
$query->bodyPart($section, array('peek' => true));
$fetch = $this->_socket->fetch($url->mailbox, $query, array('ids' => $ids_ob));
return $fetch[$url->uid]->getBodyPart($section, true);
}
// BODY[<#.>HEADER]
if (($pos = stripos($section, 'HEADER')) !== false) {
$id = $pos ? substr($section, 0, $pos - 1) : 0;
$query = new Horde_Imap_Client_Fetch_Query();
$query->headerText(array('id' => $id, 'peek' => true));
$fetch = $this->_socket->fetch($url->mailbox, $query, array('ids' => $ids_ob));
return $fetch[$url->uid]->getHeaderText($id, Horde_Imap_Client_Data_Fetch::HEADER_STREAM);
}
// BODY[<#.>TEXT]
if (($pos = stripos($section, 'TEXT')) !== false) {
$id = $pos ? substr($section, 0, $pos - 1) : 0;
$query = new Horde_Imap_Client_Fetch_Query();
$query->bodyText(array('id' => $id, 'peek' => true));
$fetch = $this->_socket->fetch($url->mailbox, $query, array('ids' => $ids_ob));
return $fetch[$url->uid]->getBodyText($id, true);
}
// BODY[<#.>MIMEHEADER]
if (($pos = stripos($section, 'MIME')) !== false) {
$id = $pos ? substr($section, 0, $pos - 1) : 0;
$query = new Horde_Imap_Client_Fetch_Query();
$query->mimeHeader($id, array('peek' => true));
$fetch = $this->_socket->fetch($url->mailbox, $query, array('ids' => $ids_ob));
return $fetch[$url->uid]->getMimeHeader($id, Horde_Imap_Client_Data_Fetch::HEADER_STREAM);
}
return null;
}
示例3: getmsg
private function getmsg()
{
$headers = array();
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
// $fetch_query->fullText();
$fetch_query->bodyText();
$fetch_query->flags();
$fetch_query->seq();
$fetch_query->size();
$fetch_query->uid();
$fetch_query->imapDate();
$headers = array_merge($headers, array('importance', 'list-post', 'x-priority'));
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, array('cache' => true, 'peek' => true));
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$ids = new \Horde_Imap_Client_Ids($this->message_id);
$headers = $this->conn->fetch($this->folder_id, $fetch_query, array('ids' => $ids));
$this->plainmsg = $headers[$this->message_id]->getBodyText();
//
// // HEADER
// $this->header = $this->conn->fetchHeader($this->folder_id, $this->message_id);
//
// // BODY
// $bodystructure= $this->conn->getStructure($this->folder_id, $this->message_id);
// $a= \rcube_imap_generic::getStructurePartData($bodystructure, 0);
// if ($a['type'] == 'multipart') {
// for ($i=0; $i < count($bodystructure); $i++) {
// if (!is_array($bodystructure[$i]))
// break;
// $this->getpart($bodystructure[$i],$i+1);
// }
// } else {
// // get part no 1
// $this->getpart($bodystructure,1);
// }
}
示例4: 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+');
}
示例5: testComplexFetch
/**
* @depends testOptimizedSearches
*/
public function testComplexFetch()
{
// Fetching message information from complex MIME message.
$complex_fetch = new Horde_Imap_Client_Fetch_Query();
$complex_fetch->fullText(array('length' => 100, 'peek' => true));
// Header of entire message
$complex_fetch->headerText(array('length' => 100, 'peek' => true));
// Header of message/rfc822 part
$complex_fetch->headerText(array('id' => 2, 'length' => 100, 'peek' => true));
// Body text of entire message
$complex_fetch->bodyText(array('length' => 100, 'peek' => true));
// Body text of message/rfc822 part
$complex_fetch->bodyText(array('id' => 2, 'length' => 100, 'peek' => true));
// MIME Header of multipart/alternative part
$complex_fetch->mimeHeader('1', array('length' => 100, 'peek' => true));
// MIME Header of text/plain part embedded in message/rfc822 part
$complex_fetch->mimeHeader('2.1', array('length' => 100, 'peek' => true));
// Body text of multipart/alternative part
$complex_fetch->bodyPart('1', array('length' => 100, 'peek' => true));
// Body text of image/png part embedded in message/rfc822 part
// Try to do server-side decoding, if available
$complex_fetch->mimeHeader('2.2', array('decode' => true, 'length' => 100, 'peek' => true));
// If supported, return decoded body part size
$complex_fetch->bodyPartSize('2.2');
// Select message-id header from base message header
$complex_fetch->headers('headersearch1', array('message-id'), array('length' => 100, 'peek' => true));
// Select everything but message-id header from message/rfc822 header
$complex_fetch->headers('headersearch2', array('message-id'), array('id' => '2', 'length' => 100, 'notsearch' => true, 'peek' => true));
$complex_fetch->structure();
$complex_fetch->flags();
$complex_fetch->imapDate();
$complex_fetch->size();
$complex_fetch->uid();
if (self::$live->capability->query('CONDSTORE')) {
$complex_fetch->modseq();
}
try {
$res = self::$live->fetch(self::$test_mbox, $complex_fetch, array('ids' => new Horde_Imap_Client_Ids(3, true)));
} catch (Horde_Imap_Client_Exception $e) {
if ($e->getCode() === $e::MBOXNOMODSEQ) {
$this->markTestSkipped('Mailbox does not support MODSEQ.');
}
throw $e;
}
$this->assertInstanceOf('Horde_Imap_Client_Fetch_Results', $res);
$this->assertEquals(1, count($res));
$this->assertEquals('Message-ID: <2008yhnujm@foo.example.com>', trim($res[3]->getHeaders('headersearch1')));
/* Return stream instead. */
$this->assertInternalType('resource', $res[3]->getHeaders('headersearch1', Horde_Imap_Client_Data_Fetch::HEADER_STREAM));
/* Parse headers instead. */
$this->assertInstanceOf('Horde_Mime_Headers', $res[3]->getHeaders('headersearch1', Horde_Imap_Client_Data_Fetch::HEADER_PARSE));
}