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

PHP imap_fetchstructure函数代码示例

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

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



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

示例1: readEmails

 public function readEmails($sentTo = null, $bodyPart = null)
 {
     $host = '{imap.gmail.com:993/imap/ssl}INBOX';
     $spinner = new Spinner('Could not connect to Imap server.', 60, 10000);
     $inbox = $spinner->assertBecomesTrue(function () use($host) {
         return @imap_open($host, $this->email, $this->password);
     });
     $emails = imap_search($inbox, 'TO ' . ($sentTo ? $sentTo : $this->email));
     if ($emails) {
         $messages = [];
         foreach ($emails as $n) {
             $structure = imap_fetchstructure($inbox, $n);
             if (!$bodyPart) {
                 $part = $this->findPart($structure, function ($part) {
                     return $part->subtype === 'HTML';
                 });
             } elseif (is_callable($bodyPart)) {
                 $part = $this->findPart($structure, $bodyPart);
             } else {
                 $part = $bodyPart;
             }
             $hinfo = imap_headerinfo($inbox, $n);
             $subject = $hinfo->subject;
             $message = ['subject' => $subject, 'body' => imap_fetchbody($inbox, $n, $part)];
             $messages[] = $message;
         }
         return $messages;
     } else {
         return [];
     }
 }
开发者ID:NathanGiesbrecht,项目名称:PrestaShopAutomationFramework,代码行数:31,代码来源:GmailReader.php


示例2: getAttachments

 function getAttachments($id, $path)
 {
     $parts = imap_fetchstructure($this->mailbox, $id);
     $attachments = array();
     //FIXME if we do an is_array() here it breaks howver if we don't
     //we get foreach errors
     foreach ($parts->parts as $key => $value) {
         $encoding = $parts->parts[$key]->encoding;
         if ($parts->parts[$key]->ifdparameters) {
             $filename = $parts->parts[$key]->dparameters[0]->value;
             $message = imap_fetchbody($this->mailbox, $id, $key + 1);
             switch ($encoding) {
                 case 0:
                     $message = imap_8bit($message);
                 case 1:
                     $message = imap_8bit($message);
                 case 2:
                     $message = imap_binary($message);
                 case 3:
                     $message = imap_base64($message);
                 case 4:
                     $message = quoted_printable_decode($message);
                 case 5:
                 default:
                     $message = $message;
             }
             $fp = fopen($path . $filename, "w");
             fwrite($fp, $message);
             fclose($fp);
             $attachments[] = $filename;
         }
     }
     return $attachments;
 }
开发者ID:sitracker,项目名称:sitracker_old,代码行数:34,代码来源:fetchSitMail.class.php


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


示例4: parse_message

function parse_message($connection, $message_number, $option = null, $to_charset = 'UTF-8')
{
    $result = array('messages' => array(), 'attachments' => array());
    $structure = imap_fetchstructure($connection, $message_number, $option);
    if (isset($structure->parts)) {
        $flatten = parse_message_flatten($structure->parts);
    } else {
        $flatten = array(1 => $structure);
    }
    foreach ($flatten as $id => &$part) {
        switch ($part->type) {
            case TYPETEXT:
                $message = parse_message_decode_text($connection, $part, $message_number, $id, $option, $to_charset);
                $result['messages'][] = $message;
                break;
            case TYPEAPPLICATION:
            case TYPEAUDIO:
            case TYPEIMAGE:
            case TYPEVIDEO:
            case TYPEOTHER:
                $attachment = parse_message_decode_attach($connection, $part, $message_number, $id, $option);
                if ($attachment) {
                    $result['attachments'][] = $attachment;
                }
                break;
            case TYPEMULTIPART:
            case TYPEMESSAGE:
                break;
        }
    }
    return $result;
}
开发者ID:urueedi,项目名称:fusionpbx,代码行数:32,代码来源:parse_message.php


示例5: fetch

 public function fetch($delete = false)
 {
     $oImap = imap_open('{' . $this->mail_server . ':993/imap/ssl/notls/novalidate-cert}', $this->username, $this->password);
     $oMailboxStatus = imap_check($oImap);
     $aMessages = imap_fetch_overview($oImap, "1:{$oMailboxStatus->Nmsgs}");
     $validMessages = array();
     foreach ($aMessages as $oMessage) {
         print "Trying message '" . $oMessage->subject . "'";
         $fileContent = $fileType = '';
         $geocoder = factory::create('geocoder');
         $postCode = $geocoder->extract_postcode($oMessage->subject);
         $fromName = null;
         $fromEmail = null;
         if (strpos($oMessage->from, '<')) {
             $split = split('<', $oMessage->from);
             //name - make sure name not an email address
             $fromName = trim($split[0]);
             if (valid_email($fromName)) {
                 $fromName = null;
             }
             //email
             $fromEmail = trim(str_replace('>', '', $split[1]));
         } else {
             $fromEmail = $oMessage->from;
         }
         $images = array();
         $messageStructure = imap_fetchstructure($oImap, $oMessage->msgno);
         if (isset($messageStructure->parts)) {
             $partNumber = 0;
             foreach ($messageStructure->parts as $oPart) {
                 $partNumber++;
                 if ($oPart->subtype == 'PLAIN' && !$postCode) {
                     $messageContent = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
                     if ($oPart->encoding == 4) {
                         $messageContent = quoted_printable_decode($messageContent);
                     }
                     $postCode = geocoder::extract_postcode($messageContent);
                 } elseif ($oPart->encoding == 3 && in_array($oPart->subtype, array('JPEG', 'PNG'))) {
                     $oImage = null;
                     $encodedBody = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
                     $fileContent = base64_decode($encodedBody);
                     $oImage = imagecreatefromstring($fileContent);
                     if (imagesx($oImage) > $this->min_import_size && imagesy($oImage) > $this->min_import_size) {
                         array_push($images, $oImage);
                     }
                     $fileType = strtolower($oPart->subtype);
                 }
             }
         }
         //add to the messages array
         array_push($validMessages, array('postcode' => $postCode, 'images' => $images, 'file_type' => $fileType, 'from_address' => $fromAddress, 'from_email' => $fromEmail, 'from_name' => $fromName));
         if ($delete) {
             imap_delete($oImap, $oMessage->msgno);
         }
     }
     imap_close($oImap, CL_EXPUNGE);
     $this->messages = $validMessages;
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:58,代码来源:mail_image.php


示例6: getdata

 function getdata($host, $login, $password, $savedirpath)
 {
     $mbox = imap_open($host, $login, $password) or die("can't connect: " . imap_last_error());
     $message = array();
     $message["attachment"]["type"][0] = "text";
     $message["attachment"]["type"][1] = "multipart";
     $message["attachment"]["type"][2] = "message";
     $message["attachment"]["type"][3] = "application";
     $message["attachment"]["type"][4] = "audio";
     $message["attachment"]["type"][5] = "image";
     $message["attachment"]["type"][6] = "video";
     $message["attachment"]["type"][7] = "other";
     $buzon_destino = "cfdi";
     echo imap_createmailbox($mbox, imap_utf7_encode("{$buzon_destino}"));
     echo imap_num_msg($mbox);
     for ($jk = 1; $jk <= imap_num_msg($mbox); $jk++) {
         $structure = imap_fetchstructure($mbox, $jk);
         $parts = $structure->parts;
         $fpos = 2;
         for ($i = 1; $i < count($parts); $i++) {
             $message["pid"][$i] = $i;
             $part = $parts[$i];
             if (strtolower($part->disposition) == "attachment") {
                 $message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" . strtolower($part->subtype);
                 $message["subtype"][$i] = strtolower($part->subtype);
                 $ext = $part->subtype;
                 $params = $part->dparameters;
                 $filename = $part->dparameters[0]->value;
                 if (!($ext == 'xml' or $ext == 'XML' or $ext == 'PDF' or $ext == 'pdf')) {
                     continue;
                 }
                 $mege = "";
                 $data = "";
                 $mege = imap_fetchbody($mbox, $jk, $fpos);
                 $data = $this->getdecodevalue($mege, $part->type);
                 $fp = fopen($filename, 'w');
                 fputs($fp, $data);
                 fclose($fp);
                 $fpos += 1;
                 /* Se mueve el archiv descargado al directorio de recibidos */
                 //                    rename($filename, $savedirpath.$filename);
                 //                    printf("\nSe movio el archivo $filename");
             }
         }
         $result = imap_fetch_overview($mbox, $jk);
         echo $result[0]->from;
         //            imap_mail_move($mbox, $jk, $buzon_destino);
         //imap_delete tags a message for deletion
         //    imap_delete($mbox,$jk);
     }
     // imap_expunge deletes all tagged messages
     //                    imap_expunge($mbox);
     imap_close($mbox);
 }
开发者ID:njmube,项目名称:CSDOCSCFDI,代码行数:54,代码来源:CorreoGetAdjuntos.class.php


示例7: readMessage

 public function readMessage($messageid)
 {
     $message = array();
     $header = imap_header($this->mailbox, $messageid);
     $structure = imap_fetchstructure($this->mailbox, $messageid);
     $message['subject'] = $header->subject;
     $message['fromaddress'] = $header->fromaddress;
     $message['toaddress'] = $header->toaddress;
     //$message['ccaddress'] =   $header->ccaddress;
     $message['date'] = $header->date;
     $message['id'] = $messageid;
     if ($this->check_type($structure)) {
         $message['body'] = imap_fetchbody($this->mailbox, $messageid, "2");
         ## GET THE BODY OF MULTI-PART MESSAGE
         if (!$message['body']) {
             $message['body'] = '[NO TEXT ENTERED INTO THE MESSAGE]\\n\\n';
         }
     } else {
         $message['body'] = imap_body($this->mailbox, $messageid);
         if (!$message['body']) {
             $message['body'] = '[NO TEXT ENTERED INTO THE MESSAGE]\\n\\n';
         }
     }
     return $message;
 }
开发者ID:charvoa,项目名称:Epitech-2,代码行数:25,代码来源:imapClass.php


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


示例9: inbox

 function inbox()
 {
     $this->msg_cnt = imap_num_msg($this->conn);
     echo "Number of emails read = " . $this->msg_cnt . "\n";
     /*$in = array();
     		for($i = 1; $i <= $this->msg_cnt; $i++) {
     			$in[] = array(
     				'index'     => $i,
     				'header'    => imap_headerinfo($this->conn, $i),
     				'body'      => imap_body($this->conn, $i),
     				'structure' => imap_fetchstructure($this->conn, $i)
     			); */
     $output = '<table>';
     $output .= '<tr><th>Subject</th><th>voucher</th><th>From</th><th>seen</th><th>type</th></tr>';
     $mails = imap_search($this->conn, 'FROM "[email protected]" SUBJECT "Confirm Hotel Booking"');
     //print_r($mails);
     for ($i = 0; $i <= sizeof($mails); $i++) {
         $header = imap_fetch_overview($this->conn, $mails[$i], 0);
         $body = imap_fetchbody($this->conn, $mails[$i], 1.1);
         $output .= '<tr>';
         $output .= '<td><span class="subject">' . $header[0]->subject . '</span> </td>';
         $output .= '<td><span class="from">' . $header[0]->from . '</span></td>';
         $output .= '<td><span class="voucher">' . $mails[0]->voucher . '</span></td>';
         $output .= '<td><span class="date">' . $header[0]->date . '</span></td>>';
         $output .= '<td><span class="toggler">' . ($header[0]->seen ? 'read' : 'unread') . '"></span></td>';
         $structure = imap_fetchstructure($this->conn, $mails[$i]);
         $output .= '<td><span class="type">' . $structure->type . '</span> </td>';
         $output .= '</tr>';
     }
     $output .= '</table>';
     echo $output . "\n";
 }
开发者ID:jyotsnabuddha,项目名称:vistaram,代码行数:32,代码来源:Email_reader.php


示例10: messages

 /**
  * @param string $criteria
  * @return $this
  */
 public function messages($criteria)
 {
     $this->messages = array_map(function ($messageNumber) {
         return array('id' => $messageNumber, 'header' => imap_header($this->mailbox, $messageNumber), 'struct' => imap_fetchstructure($this->mailbox, $messageNumber));
     }, imap_search($this->mailbox, $criteria));
     return $this;
 }
开发者ID:jochenJa,项目名称:mailstuff,代码行数:11,代码来源:Mailbox.php


示例11: getBody

    /**
     *
     * @return ImapMessagePart
     */
    public function getBody() {

        if ($this->body === null) {
            $partsStructure = \imap_fetchstructure($this->imapResource, $this->uid, \FT_UID);
            $this->body = new ImapMessagePart($this->imapResource, $this->uid, $partsStructure);
        }
        return $this->body;
    }
开发者ID:nathan-gs,项目名称:Calliope,代码行数:12,代码来源:ImapMessage.php


示例12: fetchStructure

 public function fetchStructure()
 {
     $structure = imap_fetchstructure($this->stream, $this->number);
     if (FALSE === $structure) {
         throw new Exception('FetchStructure failed: ' . imap_last_error());
     }
     return $structure;
 }
开发者ID:kamaroly,项目名称:kigalilifeapp,代码行数:8,代码来源:IMAPMessage.php


示例13: __construct

 public function __construct(IMAP $imap, $mail, $attachmentsDirectory = null)
 {
     $this->imap = $imap;
     $this->connection = $imap->getConnection();
     $this->mail = $mail;
     $this->attachmentsDirectory = $attachmentsDirectory;
     $this->structure = imap_fetchstructure($this->connection, $this->mail->id, FT_UID);
 }
开发者ID:veronecrm,项目名称:mod.verone.mail,代码行数:8,代码来源:MailReader.php


示例14: getStructure

 public function getStructure()
 {
     $structure = @imap_fetchstructure($this->_connection->getConnection(), $this->_messageNumber);
     if (!$structure) {
         throw new Exception('Failed to fetch message structure.');
     }
     return $structure;
 }
开发者ID:bigwhoop,项目名称:MailControl,代码行数:8,代码来源:Message.php


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


示例16: mimeToArray

 public function mimeToArray($imap, $mid, $parse_headers = false)
 {
     $mail = imap_fetchstructure($this->conn, $mid);
     $mail = $this->getParts($this->conn, $mid, $mail, 0);
     if ($parse_headers) {
         $mail[0]["parsed"] = $this->parseHeaders($mail[0]["data"]);
     }
     return $mail;
 }
开发者ID:hmc-soft,项目名称:mvc,代码行数:9,代码来源:POP3.php


示例17: mail_mime_to_array

 function mail_mime_to_array($imap, $mid, $parse_headers = false)
 {
     $mail = imap_fetchstructure($imap, $mid);
     $mail = $this->mail_get_parts($imap, $mid, $mail, 0);
     if ($parse_headers) {
         $mail[0]["parsed"] = $this->mail_parse_headers($mail[0]["data"]);
     }
     return $mail;
 }
开发者ID:cabelotaina,项目名称:delibera,代码行数:9,代码来源:delibera_mailer_read.php


示例18: parsebody

function parsebody($conn, $msgno)
{
    $body = imap_fetchstructure($conn, $msgno);
    $att = false;
    $attachment = array();
    $inline = array();
    $content = '';
    return parseparts($conn, $msgno, $body, $attachment, $inline, $content);
}
开发者ID:xjpvictor,项目名称:SimpleBookmark,代码行数:9,代码来源:parsemail.php


示例19: fetch

 public function fetch()
 {
     $structure = @imap_fetchstructure($this->connection, $this->messageNumber, FT_UID);
     if (!$structure) {
         return false;
     } else {
         $this->recurse($structure->parts);
         return true;
     }
 }
开发者ID:Chendri,项目名称:phpemailclient,代码行数:10,代码来源:EmailMessage.php


示例20: 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);
         if (isset($header->from)) {
             $from = $header->from;
         } else {
             $from = FALSE;
         }
         $fromname = "";
         $fromaddress = "";
         $subject = "";
         if ($from != FALSE) {
             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:Bridgeborn,项目名称:Ushahidi_Web,代码行数:63,代码来源:Imap.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP imap_get_quotaroot函数代码示例发布时间:2022-05-15
下一篇:
PHP imap_fetchheader函数代码示例发布时间: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