• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imap_body函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createFromImap

 /**
  * Method to read email from imap extension and return Zend Mail Message object.
  *
  * This is bridge while migrating to Zend Mail package supporting reading from imap extension functions.
  *
  * @param resource $mbox
  * @param integer $num
  * @param array $info connection information about connection
  * @return ImapMessage
  */
 public static function createFromImap($mbox, $num, $info)
 {
     // check if the current message was already seen
     list($overview) = imap_fetch_overview($mbox, $num);
     $headers = imap_fetchheader($mbox, $num);
     $content = imap_body($mbox, $num);
     // fill with "\Seen", "\Deleted", "\Answered", ... etc
     $knownFlags = array('recent' => Zend\Mail\Storage::FLAG_RECENT, 'flagged' => Zend\Mail\Storage::FLAG_FLAGGED, 'answered' => Zend\Mail\Storage::FLAG_ANSWERED, 'deleted' => Zend\Mail\Storage::FLAG_DELETED, 'seen' => Zend\Mail\Storage::FLAG_SEEN, 'draft' => Zend\Mail\Storage::FLAG_DRAFT);
     $flags = array();
     foreach ($knownFlags as $flag => $value) {
         if ($overview->{$flag}) {
             $flags[] = $value;
         }
     }
     $message = new self(array('root' => true, 'headers' => $headers, 'content' => $content, 'flags' => $flags));
     // set MailDate to $message object, as it's not available in message headers, only in IMAP itself
     // this likely "message received date"
     $imapheaders = imap_headerinfo($mbox, $num);
     $header = new GenericHeader('X-IMAP-UnixDate', $imapheaders->udate);
     $message->getHeaders()->addHeader($header);
     $message->mbox = $mbox;
     $message->num = $num;
     $message->info = $info;
     return $message;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:35,代码来源:ImapMessage.php


示例2: get_messages

 /**
  * Get messages according to a search criteria
  * 
  * @param	string	search criteria (RFC2060, sec. 6.4.4). Set to "UNSEEN" by default
  *					NB: Search criteria only affects IMAP mailboxes.
  * @param	string	date format. Set to "Y-m-d H:i:s" by default
  * @return	mixed	array containing messages
  */
 public function get_messages($search_criteria = "UNSEEN", $date_format = "Y-m-d H:i:s")
 {
     $msgs = imap_search($this->imap_stream, $search_criteria);
     $no_of_msgs = $msgs ? count($msgs) : 0;
     $messages = array();
     for ($i = 0; $i < $no_of_msgs; $i++) {
         // Get Message Unique ID in case mail box changes
         // in the middle of this operation
         $message_id = imap_uid($this->imap_stream, $msgs[$i]);
         $header = imap_header($this->imap_stream, $message_id);
         $date = date($date_format, $header->udate);
         $from = $header->from;
         $fromname = "";
         $fromaddress = "";
         $subject = "";
         foreach ($from as $id => $object) {
             if (isset($object->personal)) {
                 $fromname = $object->personal;
             }
             $fromaddress = $object->mailbox . "@" . $object->host;
             if ($fromname == "") {
                 // In case from object doesn't have Name
                 $fromname = $fromaddress;
             }
         }
         if (isset($header->subject)) {
             $subject = $this->_mime_decode($header->subject);
         }
         $structure = imap_fetchstructure($this->imap_stream, $message_id);
         $body = '';
         if (!empty($structure->parts)) {
             for ($j = 0, $k = count($structure->parts); $j < $k; $j++) {
                 $part = $structure->parts[$j];
                 if ($part->subtype == 'PLAIN') {
                     $body = imap_fetchbody($this->imap_stream, $message_id, $j + 1);
                 }
             }
         } else {
             $body = imap_body($this->imap_stream, $message_id);
         }
         // Convert quoted-printable strings (RFC2045)
         $body = imap_qprint($body);
         array_push($messages, array('msg_no' => $message_id, 'date' => $date, 'from' => $fromname, 'email' => $fromaddress, 'subject' => $subject, 'body' => $body));
         // Mark Message As Read
         imap_setflag_full($this->imap_stream, $message_id, "\\Seen");
     }
     return $messages;
 }
开发者ID:shukster,项目名称:Cuidemos-el-Voto,代码行数:56,代码来源:Imap.php


示例3: bounceprocessing

 /**
  * tokens::bounceprocessing()
  *
  * @return void
  */
 function bounceprocessing($iSurveyId)
 {
     $iSurveyId = sanitize_int($iSurveyId);
     $clang = $this->getController()->lang;
     $bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
     if (!$bTokenExists) {
         $clang->eT("No token table.");
         return;
     }
     $thissurvey = getSurveyInfo($iSurveyId);
     if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update')) {
         $clang->eT("We are sorry but you don't have permissions to do this.");
         return;
     }
     if ($thissurvey['bounceprocessing'] != 'N' || $thissurvey['bounceprocessing'] == 'G' && getGlobalSetting('bounceaccounttype') != 'off') {
         if (!function_exists('imap_open')) {
             $clang->eT("The imap PHP library is not installed. Please contact your system administrator.");
             return;
         }
         $bouncetotal = 0;
         $checktotal = 0;
         if ($thissurvey['bounceprocessing'] == 'G') {
             $accounttype = strtoupper(getGlobalSetting('bounceaccounttype'));
             $hostname = getGlobalSetting('bounceaccounthost');
             $username = getGlobalSetting('bounceaccountuser');
             $pass = getGlobalSetting('bounceaccountpass');
             $hostencryption = strtoupper(getGlobalSetting('bounceencryption'));
         } else {
             $accounttype = strtoupper($thissurvey['bounceaccounttype']);
             $hostname = $thissurvey['bounceaccounthost'];
             $username = $thissurvey['bounceaccountuser'];
             $pass = $thissurvey['bounceaccountpass'];
             $hostencryption = strtoupper($thissurvey['bounceaccountencryption']);
         }
         @(list($hostname, $port) = split(':', $hostname));
         if (empty($port)) {
             if ($accounttype == "IMAP") {
                 switch ($hostencryption) {
                     case "OFF":
                         $hostname = $hostname . ":143";
                         break;
                     case "SSL":
                         $hostname = $hostname . ":993";
                         break;
                     case "TLS":
                         $hostname = $hostname . ":993";
                         break;
                 }
             } else {
                 switch ($hostencryption) {
                     case "OFF":
                         $hostname = $hostname . ":110";
                         break;
                     case "SSL":
                         $hostname = $hostname . ":995";
                         break;
                     case "TLS":
                         $hostname = $hostname . ":995";
                         break;
                 }
             }
         } else {
             $hostname = $hostname . ":" . $port;
         }
         $flags = "";
         switch ($accounttype) {
             case "IMAP":
                 $flags .= "/imap";
                 break;
             case "POP":
                 $flags .= "/pop3";
                 break;
         }
         switch ($hostencryption) {
             case "OFF":
                 $flags .= "/notls";
                 // Really Off
                 break;
             case "SSL":
                 $flags .= "/ssl/novalidate-cert";
                 break;
             case "TLS":
                 $flags .= "/tls/novalidate-cert";
                 break;
         }
         if ($mbox = @imap_open('{' . $hostname . $flags . '}INBOX', $username, $pass)) {
             imap_errors();
             $count = imap_num_msg($mbox);
             if ($count > 0) {
                 $lasthinfo = imap_headerinfo($mbox, $count);
                 $datelcu = strtotime($lasthinfo->date);
                 $datelastbounce = $datelcu;
                 $lastbounce = $thissurvey['bouncetime'];
                 while ($datelcu > $lastbounce) {
                     @($header = explode("\r\n", imap_body($mbox, $count, FT_PEEK)));
//.........这里部分代码省略.........
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:101,代码来源:tokens.php


示例4: get_messages

 /**
 * Get messages according to a search criteria
 * 
 * @param	string	search criteria (RFC2060, sec. 6.4.4). Set to "UNSEEN" by default
 					NB: Search criteria only affects IMAP mailboxes.
 * @param	string	date format. Set to "Y-m-d H:i:s" by default
 * @return	mixed	array containing messages
 */
 public function get_messages($search_criteria = "UNSEEN", $date_format = "Y-m-d H:i:s")
 {
     $msgs = imap_search($this->imap_stream, $search_criteria);
     $no_of_msgs = $msgs ? count($msgs) : 0;
     $messages = array();
     for ($i = 0; $i < $no_of_msgs; $i++) {
         $header = imap_header($this->imap_stream, $msgs[$i]);
         $date = date($date_format, $header->udate);
         $from = $this->_mime_decode($header->fromaddress);
         $subject = $this->_mime_decode($header->subject);
         $structure = imap_fetchstructure($this->imap_stream, $msgs[$i]);
         if (!empty($structure->parts)) {
             for ($j = 0, $k = count($structure->parts); $j < $k; $j++) {
                 $part = $structure->parts[$j];
                 if ($part->subtype == 'PLAIN') {
                     $body = imap_fetchbody($this->imap_stream, $msgs[$i], $j + 1);
                 }
             }
         } else {
             $body = imap_body($this->imap_stream, $msgs[$i]);
         }
         // Convert quoted-printable strings (RFC2045)
         $body = imap_qprint($body);
         array_push($messages, array('msg_no' => $msgs[$i], 'date' => $date, 'from' => $from, 'subject' => $subject, 'body' => $body));
     }
     return $messages;
 }
开发者ID:ajturner,项目名称:ushahidi,代码行数:35,代码来源:Imap.php


示例5: checkMessages

 /**
  * @param resource $imapConnection
  * @param array    $messages
  * @param bool     $clean
  *
  * @return bool Return <em>true</em> if <strong>all</strong> messages exist in the inbox.
  */
 public function checkMessages($imapConnection, array $messages, $clean = true)
 {
     $bodies = array_map(function ($message) {
         return $message->getText() . "\r\n";
     }, $messages);
     $host = $_ENV['AVISOTA_TEST_IMAP_HOST'] ?: getenv('AVISOTA_TEST_IMAP_HOST');
     $hits = 0;
     for ($i = 0; $i < 30 && $hits < count($bodies); $i++) {
         // wait for the mail server
         sleep(2);
         imap_gc($imapConnection, IMAP_GC_ENV);
         $status = imap_status($imapConnection, '{' . $host . '}', SA_MESSAGES);
         for ($j = $status->messages; $j > 0; $j--) {
             $body = imap_body($imapConnection, $j);
             if (in_array($body, $bodies)) {
                 $hits++;
                 if ($clean) {
                     imap_delete($imapConnection, $j);
                 }
             }
         }
         imap_expunge($imapConnection);
     }
     return $hits;
 }
开发者ID:avisota,项目名称:core,代码行数:32,代码来源:ImapMailboxChecker.php


示例6: inbox

 function inbox()
 {
     $this->msg_cnt = imap_num_msg($this->conn);
     $in = array();
     for ($i = 1; $i <= 20; $i++) {
         $in[] = array('index' => $i, 'header' => imap_headerinfo($this->conn, $i), 'body' => imap_body($this->conn, $i), 'structure' => imap_fetchstructure($this->conn, $i));
     }
     $this->inbox = $in;
 }
开发者ID:networksoft,项目名称:erp.multinivel,代码行数:9,代码来源:Email_reader.php


示例7: retrieve_message

function retrieve_message($mbox, $messageid, $including = 0)
{
    $message = '';
    $structure = imap_fetchstructure($mbox, $messageid);
    if ($structure->type == 1) {
        // Если MULTI-PART письмо
        $message = imap_fetchbody($mbox, $messageid, $including + 1);
        $parameters = $structure->parts[$including]->parameters;
        $encoding = $structure->parts[$including]->encoding;
    } else {
        $message = imap_body($mbox, $messageid);
        $parameters = $structure->parameters;
        $encoding = $structure->encoding;
    }
    // if
    switch ($encoding) {
        // Декодируем
        case 0:
            // 7BIT
        // 7BIT
        case 1:
            // 8BIT
        // 8BIT
        case 2:
            // BINARY
            break;
        case 3:
            // BASE64
            $message = base64_decode($message);
            break;
        case 4:
            // QUOTED-PRINTABLE
            $message = quoted_printable_decode($message);
            break;
        case 5:
            // OTHER
        // OTHER
        default:
            // UNKNOWN
            return;
    }
    // switch
    $charset = '';
    for ($i = 0; $i < count($parameters); $i++) {
        if ($parameters[$i]->attribute == 'charset') {
            $charset = $parameters[$i]->value;
        }
    }
    return array($message, $charset);
}
开发者ID:pombredanne,项目名称:lishnih,代码行数:50,代码来源:func.php


示例8: free

 public function free($util)
 {
     $stream = imap_open("{imap.club-internet.fr:993/imap/SSL}", $util, "wrasuxwr");
     var_dump($stream);
     $check = imap_check($stream);
     $list = imap_list($stream, "{imap.club-internet.fr}", "*");
     imap_createmailbox($stream, '{imap.club-internet.fr}brubru');
     $getmailboxes = imap_getmailboxes($stream, "{imap.club-internet.fr}", "*");
     $headers = imap_headers($stream);
     $num_msg = imap_num_msg($stream);
     $status = imap_status($stream, "{imap.club-internet.fr:993/imap/SSL}INBOX", SA_ALL);
     $messages = imap_fetch_overview($stream, "1:" . $num_msg);
     $structure = imap_fetchstructure($stream, 2);
     $body = utf8_encode(quoted_printable_decode(imap_body($stream, '2')));
     // imap_delete($stream, '1');
     // imap_expunge($stream);
     return view('Imap.Imap')->with(compact('resource'))->with(compact('check'))->with(compact('list'))->with(compact('getmailboxes'))->with(compact('headers'))->with(compact('num_msg'))->with(compact('status'))->with(compact('errors'))->with(compact('messages'))->with(compact('structure'))->with(compact('body'));
 }
开发者ID:gAb09,项目名称:NetP,代码行数:18,代码来源:ImapController.php


示例9: retrieve_message

function retrieve_message($auth_user, $accountid, $messageid, $fullheaders)
{
    $message = array();
    if (!($auth_user && $messageid && $accountid)) {
        return false;
    }
    $imap = open_mailbox($auth_user, $accountid);
    if (!$imap) {
        return false;
    }
    $header = imap_header($imap, $messageid);
    if (!$header) {
        return false;
    }
    $message['body'] = imap_body($imap, $messageid);
    if (!$message['body']) {
        $message['body'] = "[This message has no body]\n\n\n\n\n\n";
    }
    if ($fullheaders) {
        $message['fullheaders'] = imap_fetchheader($imap, $messageid);
    } else {
        $message['fullheaders'] = '';
    }
    $message['subject'] = $header->subject;
    $message['fromaddress'] = $header->fromaddress;
    $message['toaddress'] = $header->toaddress;
    $message['ccaddress'] = $header->ccaddress;
    $message['date'] = $header->date;
    // note we can get more detailed information by using from and to
    // rather than fromaddress and toaddress, but these are easier
    imap_close($imap);
    return $message;
}
开发者ID:andersonbporto,项目名称:programacao_internet_2015_1,代码行数:33,代码来源:mail_fns.php


示例10: fetch

 public function fetch(MailCriteria $criteria, $callback)
 {
     $mailbox = @imap_open('{' . $this->host . ':' . $this->port . '}INBOX', $this->username, $this->password);
     if (!$mailbox) {
         throw new ImapException("Cannot connect to imap server: {$this->host}:{$this->port}'");
     }
     $this->checkProcessedFolder($mailbox);
     $emails = $this->fetchEmails($mailbox, $criteria);
     if ($emails) {
         foreach ($emails as $emailIndex) {
             $overview = imap_fetch_overview($mailbox, $emailIndex, 0);
             $message = imap_body($mailbox, $emailIndex);
             $email = new Email($overview, $message);
             $processed = $callback($email);
             if ($processed) {
                 $res = imap_mail_move($mailbox, $emailIndex, $this->processedFolder);
                 if (!$res) {
                     throw new \Exception("Unexpected error: Cannot move email to ");
                     break;
                 }
             }
         }
     }
     @imap_close($mailbox);
 }
开发者ID:martinstrycek,项目名称:imap-mail-downloader,代码行数:25,代码来源:Downloader.php


示例11: getpart

function getpart($mbox, $mid, $p, $partno, $charset, $htmlmsg, $plainmsg, $attachments)
{
    // $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple
    // DECODE DATA
    if ($p->encoding != 3 || $partno < 2) {
        $data = $partno ? imap_fetchbody($mbox, $mid, $partno, FT_UID) : imap_body($mbox, $mid, FT_UID);
    }
    // simple
    // Any part may be encoded, even plain text messages, so check everything.
    if ($p->encoding == 4) {
        $data = quoted_printable_decode($data);
    } elseif ($p->encoding == 3) {
        $data = base64_decode($data);
    }
    // PARAMETERS
    // get all parameters, like charset, filenames of attachments, etc.
    $params = array();
    if ($p->parameters) {
        foreach ($p->parameters as $x) {
            $params[strtolower($x->attribute)] = $x->value;
        }
    }
    if ($p->dparameters) {
        foreach ($p->dparameters as $x) {
            $params[strtolower($x->attribute)] = $x->value;
        }
    }
    // ATTACHMENT
    // Any part with a filename is an attachment,
    // so an attached text file (type 0) is not mistaken as the message.
    if ($params['filename'] || $params['name']) {
        // filename may be given as 'Filename' or 'Name' or both
        $filename = $params['filename'] ? $params['filename'] : $params['name'];
        // filename may be encoded, so see imap_mime_header_decode()
        $attachments[$filename] = $data;
        // this is a problem if two files have same name
    }
    // TEXT
    if ($p->type == 0 && $data) {
        // Messages may be split in different parts because of inline attachments,
        // so append parts together with blank row.
        if (strtolower($p->subtype) == 'plain') {
            $plainmsg .= trim($data) . "\n\n";
        } else {
            $htmlmsg .= $data . "<br /><br />";
        }
        $charset = $params['charset'];
        // assume all parts are same charset
    } elseif ($p->type == 2 && $data) {
        $plainmsg .= $data . "\n\n";
    }
    // SUBPART RECURSION
    if ($p->parts) {
        foreach ($p->parts as $partno0 => $p2) {
            list($charset, $htmlmsg, $plainmsg, $attachments) = getpart($mbox, $mid, $p2, $partno . '.' . ($partno0 + 1), $charset, $htmlmsg, $plainmsg, $attachments);
        }
        // 1.2, 1.2.1, etc.
    }
    return array($charset, $htmlmsg, $plainmsg, $attachments);
}
开发者ID:zenp76,项目名称:dolibarr-webmail-module,代码行数:60,代码来源:lib_dolimail.php


示例12: get_part

 function get_part($ret, $mid, $p, $partno)
 {
     // DECODE DATA
     $data = $partno ? imap_fetchbody($this->con, $mid, $partno) : imap_body($this->con, $mid);
     // simple
     // Any part may be encoded, even plain text messages, so check everything.
     if ($p->encoding == 4) {
         $data = quoted_printable_decode($data);
     } elseif ($p->encoding == 3) {
         $data = base64_decode($data);
     }
     // PARAMETERS
     // get all parameters, like charset, filenames of attachments, etc.
     $params = array();
     if (isset($p->parameters)) {
         foreach ($p->parameters as $x) {
             $params[strtolower($x->attribute)] = $x->value;
         }
     }
     if (isset($p->dparameters)) {
         foreach ($p->dparameters as $x) {
             $params[strtolower($x->attribute)] = $x->value;
         }
     }
     // ATTACHMENT
     // Any part with a filename is an attachment,
     // so an attached text file (type 0) is not mistaken as the message.
     if (!empty($params['filename']) || !empty($params['name'])) {
         // filename may be given as 'Filename' or 'Name' or both
         $filename = empty($params['filename']) ? $params['name'] : $params['filename'];
         // filename may be encoded, so see imap_mime_header_decode()
         $ret->attachments[$filename] = $data;
         // this is a problem if two files have same name
     }
     // TEXT
     if ($p->type == 0 && $data) {
         // Messages may be split in different parts because of inline attachments,
         // so append parts together with blank row.
         if (strtolower($p->subtype) == 'plain') {
             $ret->plainmsg .= trim($data) . "\n\n";
         } else {
             $ret->htmlmsg .= $data . "<br><br>";
         }
         $ret->charset = $params['charset'];
         // assume all parts are same charset
     } elseif ($p->type == 2 && $data) {
         $ret->plainmsg .= $data . "\n\n";
     }
     // SUBPART RECURSION
     if (!empty($p->parts)) {
         foreach ($p->parts as $partno0 => $p2) {
             $subpart = new \stdClass();
             $subpart->htmlmsg = $subpart->plainmsg = $subpart->charset = '';
             $subpart->attachments = array();
             $ret->subpart = $subpart;
             $this->get_part($subpart, $mid, $p2, $partno . '.' . ($partno0 + 1));
             // 1.2, 1.2.1, etc.
         }
     }
 }
开发者ID:splitice,项目名称:radical-mail,代码行数:60,代码来源:IMAP.php


示例13: getMail

 /**
  * Gets the mail from the inbox
  * Reads all the messages there, and adds posts based on them. Then it deletes the entire mailbox.
  */
 function getMail()
 {
     $config = Config::current();
     if (time() - 60 * $config->emailblog_minutes >= $config->emailblog_mail_checked) {
         $hostname = '{' . $config->emailblog_server . '}INBOX';
         # this isn't working well on localhost
         $username = $config->emailblog_address;
         $password = $config->emailblog_pass;
         $subjpass = $config->emailblog_subjpass;
         $inbox = imap_open($hostname, $username, $password) or exit("Cannot connect to Gmail: " . imap_last_error());
         $emails = imap_search($inbox, 'SUBJECT "' . $subjpass . '"');
         if ($emails) {
             rsort($emails);
             foreach ($emails as $email_number) {
                 $message = imap_body($inbox, $email_number);
                 $overview = imap_headerinfo($inbox, $email_number);
                 imap_delete($inbox, $email_number);
                 $title = htmlspecialchars($overview->Subject);
                 $title = preg_replace($subjpass, "", $title);
                 $clean = strtolower($title);
                 $body = htmlspecialchars($message);
                 # The subject of the email is used as the post title
                 # the content of the email is used as the body
                 # not sure about compatibility with images or audio feathers
                 Post::add(array("title" => $title, "body" => $message), $clean, Post::check_url($clean), "text");
             }
         }
         # close the connection
         imap_close($inbox, CL_EXPUNGE);
         $config->set("emailblog_mail_checked", time());
     }
 }
开发者ID:betsyzhang,项目名称:chyrp,代码行数:36,代码来源:emailblog.php


示例14: get_message

 function get_message($uid)
 {
     $raw_header = imap_fetchheader($this->stream, $uid, FT_UID);
     $raw_body = imap_body($this->stream, $uid, FT_UID);
     $message = new Email_Parser($raw_header . $raw_body);
     return $message;
 }
开发者ID:optimumweb,项目名称:php-email-reader-parser,代码行数:7,代码来源:email_reader.php


示例15: get_message

	function get_message($msg)
	{
		$header = imap_fetchheader($this->_connection, $msg);
		echo "<h1>header {$msg}:</h1><br>".$header;
		$message = imap_body($this->_connection, $msg);
		echo "<h1>message {$msg}:</h1><br>".$message;
		return $header.$message;
	}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:8,代码来源:pop3_socket.class.php


示例16: imap_read_mail

 function imap_read_mail($mail_id)
 {
     $mail_header = imap_header($this->conn, $mail_id);
     $mail_body = imap_body($this->conn, $mail_id);
     foreach ($mail_header as $mail_head) {
         $mail[] = $mail_head;
     }
     $mail['body'] = $mail_body;
     return $mail;
 }
开发者ID:hardikamutech,项目名称:campaign,代码行数:10,代码来源:_imap_helper.php


示例17: get_messages

 /**
  * Get messages according to a search criteria
  * 
  * @param	string	search criteria (RFC2060, sec. 6.4.4). Set to "UNSEEN" by default
  *					NB: Search criteria only affects IMAP mailboxes.
  * @param	string	date format. Set to "Y-m-d H:i:s" by default
  * @return	mixed	array containing messages
  */
 public function get_messages($search_criteria = "UNSEEN", $date_format = "Y-m-d H:i:s")
 {
     //$msgs = imap_num_msg($this->imap_stream);
     $no_of_msgs = imap_num_msg($this->imap_stream);
     $messages = array();
     for ($i = 1; $i <= $no_of_msgs; $i++) {
         $header = imap_headerinfo($this->imap_stream, $i);
         $message_id = $header->message_id;
         $date = date($date_format, $header->udate);
         $from = $header->from;
         $fromname = "";
         $fromaddress = "";
         $subject = "";
         foreach ($from as $id => $object) {
             if (isset($object->personal)) {
                 $fromname = $object->personal;
             }
             $fromaddress = $object->mailbox . "@" . $object->host;
             if ($fromname == "") {
                 // In case from object doesn't have Name
                 $fromname = $fromaddress;
             }
         }
         if (isset($header->subject)) {
             $subject = $this->_mime_decode($header->subject);
         }
         // Read the message structure
         $structure = imap_fetchstructure($this->imap_stream, $i);
         if (!empty($structure->parts)) {
             for ($j = 0, $k = count($structure->parts); $j < $k; $j++) {
                 $part = $structure->parts[$j];
                 if ($part->subtype == 'PLAIN') {
                     $body = imap_fetchbody($this->imap_stream, $i, $j + 1);
                 }
             }
         } else {
             $body = imap_body($this->imap_stream, $i);
         }
         // Convert quoted-printable strings (RFC2045)
         $body = imap_qprint($body);
         // Convert to valid UTF8
         $body = htmlentities($body);
         $subject = htmlentities($subject);
         array_push($messages, array('message_id' => $message_id, 'date' => $date, 'from' => $fromname, 'email' => $fromaddress, 'subject' => $subject, 'body' => $body));
         // Mark Message As Read
         imap_setflag_full($this->imap_stream, $i, "\\Seen");
     }
     return $messages;
 }
开发者ID:jetherton,项目名称:Ushahidi_Web,代码行数:57,代码来源:Imap.php


示例18: getMails

    public function getMails()
    {
        $this->open();

        $MC = imap_check($this->resource);
        $result = imap_fetch_overview($this->resource, "1:{$MC->Nmsgs}", 0);

        $mail = array();
        for ($x = 0; $x < $MC->Nmsgs; $x++)
        {
            $mail[$x] = imap_header($this->resource, $x + 1);
            $mail[$x]->body = utf8_encode(imap_body($this->resource, $x + 1));
        }
        $this->close();
        return $mail;

    }
开发者ID:hlag,项目名称:svs,代码行数:17,代码来源:ImapMailer.php


示例19: getEmailInfo

 public function getEmailInfo($messageNumber)
 {
     $body = nl2br(strip_tags(imap_body($this->conn, $messageNumber)));
     $header = imap_header($this->conn, $messageNumber);
     // For getting From and then display name/email address
     $from2 = $header->from;
     // Get display from name and email address:
     $fromname = $fromaddress = '';
     foreach ($from2 as $id => $object) {
         $fromname = property_exists($object, 'personal') ? $object->personal : '';
         $fromaddress = property_exists($object, 'mailbox') ? $object->mailbox . "@" . $object->host : '';
     }
     // End foreach.
     $mailHeader = imap_headerinfo($this->conn, $messageNumber);
     // For gleaning subject and date.
     $subject = strip_tags($mailHeader->subject);
     $date = $mailHeader->date;
     return array($body, $fromname, $fromaddress, $subject, $date);
 }
开发者ID:bas2,项目名称:classes,代码行数:19,代码来源:Emailcheck.php


示例20: get_plain_text_body

function get_plain_text_body($mbox, $msgNum, &$attachments = array())
{
    $structure = imap_fetchstructure($mbox, $msgNum);
    // only plain text
    if ('PLAIN' == $structure->subtype) {
        return trim(imap_qprint(imap_body($mbox, $msgNum)));
    }
    if (isset($structure->parts)) {
        // get attachments
        foreach ($structure->parts as $partNum => $part) {
            if (in_array($part->subtype, array('JPEG', 'PNG', 'GIF'))) {
                // oeh an image
                $name = 'image-from-email-' . $msgNum . '.' . strtolower($part->subtype);
                foreach ($part->parameters as $param) {
                    if ('NAME' == $param->attribute) {
                        $name = $param->value;
                    }
                }
                $data = imap_fetchbody($mbox, $msgNum, (string) ($partNum + 1));
                file_put_contents($attachments[] = 'attachments/' . time() . '--' . $name, base64_decode($data));
            }
        }
        // multipart (probably) -- look for plain text part
        foreach ($structure->parts as $partNum => $part) {
            if ('PLAIN' == $part->subtype) {
                $body = imap_fetchbody($mbox, $msgNum, (string) ($partNum + 1));
                return trim($body);
            } else {
                if ('ALTERNATIVE' == $part->subtype && isset($part->parts)) {
                    foreach ($part->parts as $subPartNum => $subPart) {
                        if ('PLAIN' == $subPart->subtype) {
                            $body = imap_fetchbody($mbox, $msgNum, $partNum + 1 . '.' . ($subPartNum + 1));
                            return trim($body);
                        }
                    }
                }
            }
        }
    }
}
开发者ID:rudiedirkx,项目名称:IMAP-reader,代码行数:40,代码来源:test.br-autohelpdesk.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imap_bodystruct函数代码示例发布时间:2022-05-15
下一篇:
PHP imap_binary函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap