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

PHP imap_fetchbody函数代码示例

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

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



在下文中一共展示了imap_fetchbody函数的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: 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


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


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


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


示例8: listNew

 public function listNew($user_id, $filter)
 {
     $inbox = $this->getInbox($user_id);
     if ($filter == '') {
         $filter = 'UNSEEN';
     } else {
         $filter = 'UNSEEN CC "t' . $filter . '@' . $this->domain . '"';
     }
     $emails = imap_search($inbox, $filter);
     $msgs = array();
     $ids = array();
     for ($start = count($emails); $start > 0;) {
         $start--;
         $ids[] = $emails[$start];
     }
     $overviews = imap_fetch_overview($inbox, implode(',', $ids));
     foreach ($overviews as $overview) {
         $msg_no = $overview->msgno;
         $message = isset($overview->subject) ? $overview->subject : imap_fetchbody($inbox, $msg_no, '1');
         $from = $overview->from;
         if (($pos = strpos($from, '<')) !== FALSE) {
             $sender_name = substr($from, 0, $pos);
             $pos2 = strpos($from, '@', $pos);
             $sender_id = substr($from, $pos + 2, $pos2 - $pos - 2);
         }
         $msgs[] = array('id' => $msg_no, 'sender_id' => $sender_id, 'sender_name' => $sender_name, 'date' => $overview->udate, 'msg' => json_decode($message), 'seen' => $overview->seen);
     }
     $unreads = imap_search($inbox, "UNSEEN");
     if ($unreads) {
         imap_setflag_full($inbox, implode(',', $unreads), '\\Seen');
     }
     return $msgs;
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:33,代码来源:EmailBasedNotify.php


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


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


示例11: emailDeliverFailBySubject

 public static function emailDeliverFailBySubject($subject)
 {
     $mailcnf = "outlook.office365.com:993/imap/ssl/novalidate-cert";
     $username = MAILACCOUNT;
     $pw = MAILPASSWORD;
     $conn_str = "{" . $mailcnf . "}INBOX";
     $inbox = imap_open($conn_str, $username, $pw) or die('Cannot connect to mail: ' . imap_last_error());
     /* grab emails */
     $emails = imap_search($inbox, 'SUBJECT "Undeliverable: ' . $subject . '"');
     $failedInfo = [];
     /* if emails are returned, cycle through each... */
     if ($emails) {
         /* for every email... */
         foreach ($emails as $email_number) {
             /* get information specific to this email */
             $body = imap_fetchbody($inbox, $email_number, 2);
             $list = split('; ', $body);
             $sender = $list[2];
             $sender_email = explode("\n", $sender)[0];
             array_push($failedInfo, trim($sender_email));
         }
     }
     /* close the connection */
     imap_close($inbox);
     return $failedInfo;
 }
开发者ID:aanyun,项目名称:PHP-Sample-Code,代码行数:26,代码来源:EmailController.php


示例12: GetIMAPContent

 /**
  * Gets IMAP content
  *
  * @param string $imapHost
  * @param string $imapUser
  * @param string $imapPassword
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  *
  * @return $contentItems[]
  */
 private function GetIMAPContent($imapHost, $imapUser, $imapPassword, $channel)
 {
     $imapResource = imap_open("{" . $imapHost . "}INBOX", $imapUser, $imapPassword);
     //Open up unseen messages
     $imapEmails = imap_search($imapResource, strtoupper($channel->subType));
     $contentItems = array();
     if ($imapEmails) {
         //Put newest emails on top
         rsort($imapEmails);
         foreach ($imapEmails as $Email) {
             //Loop through each email and return the content
             $email_overview = imap_fetch_overview($imapResource, $Email, 0);
             $email_message = imap_fetchbody($imapResource, $Email, 2);
             $source_name = $imapUser;
             $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name);
             $source->name = $source_name;
             $source->parent = $channel->id;
             $source->type = $channel->type;
             $source->subType = $channel->subType;
             $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
             $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $email_overview[0]->subject, array($email_message));
             //the message
             $item->link = null;
             $item->date = $email_overview[0]->date;
             $contentItems[] = $item;
         }
         imap_close($imapResource);
         return $contentItems;
     }
     imap_close($imapResource);
     return null;
 }
开发者ID:Bridgeborn,项目名称:Swiftriver,代码行数:42,代码来源:IMAPParser.php


示例13: mail_decode_part

function mail_decode_part($connection, $message_number, $part, $prefix)
{
    $attachment = array();
    if ($part->ifdparameters) {
        foreach ($part->dparameters as $object) {
            $attachment[strtolower($object->attribute)] = $object->value;
            if (strtolower($object->attribute) == 'filename') {
                $attachment['is_attachment'] = true;
                $attachment['filename'] = $object->value;
            }
        }
    }
    if ($part->ifparameters) {
        foreach ($part->parameters as $object) {
            $attachment[strtolower($object->attribute)] = $object->value;
            if (strtolower($object->attribute) == 'name') {
                $attachment['is_attachment'] = true;
                $attachment['name'] = $object->value;
            }
        }
    }
    $attachment['data'] = imap_fetchbody($connection, $message_number, $prefix);
    if ($part->encoding == 3) {
        // 3 = BASE64
        $attachment['data'] = base64_decode($attachment['data']);
    } elseif ($part->encoding == 4) {
        // 4 = QUOTED-PRINTABLE
        $attachment['data'] = quoted_printable_decode($attachment['data']);
    }
    return $attachment;
}
开发者ID:heldersepu,项目名称:hs-arduino,代码行数:31,代码来源:pop3_functions.php


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


示例15: emailListener

function emailListener()
{
    $connection = establishConnection();
    $dbConn = establishDBConnection();
    $messagestatus = "UNSEEN";
    $emails = imap_search($connection, $messagestatus);
    if ($emails) {
        rsort($emails);
        foreach ($emails as $email_number) {
            // echo "in email loop";
            $header = imap_headerinfo($connection, $email_number);
            $message = imap_fetchbody($connection, $email_number, 1.1);
            if ($message == "") {
                $message = imap_fetchbody($connection, $email_number, 1);
            }
            $emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1));
            if (!detectOOOmessage($header->subject, $message, $emailaddress)) {
                detectBIOmessage($header->subject, $emailaddress);
            }
            imap_delete($connection, 1);
            //this might bug out but should delete the top message that was just parsed
        }
    }
    $dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(NOW(), INTERVAL -1 DAY) limit 1");
    //delete mentors that have been away for more than 24 hours from the away list
}
开发者ID:acuba001,项目名称:Collaborative-Platform,代码行数:26,代码来源:AutoBackendOutOfTimeShow.php


示例16: GetIMAPContent

 /**
  * Gets IMAP content
  *
  * @param string $imapHost
  * @param string $imapUser
  * @param string $imapPassword
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  *
  * @return $contentItems[]
  */
 private function GetIMAPContent($imapHost, $imapUser, $imapPassword, $channel)
 {
     $imapResource = imap_open("{" . $imapHost . "}INBOX", $imapUser, $imapPassword);
     //Open up unseen messages
     $search = $channel->lastSuccess == null ? "UNSEEN" : "UNSEEN SINCE " . \date("Y-m-d", $channel->lastSuccess);
     $imapEmails = imap_search($imapResource, $search);
     $contentItems = array();
     if ($imapEmails) {
         //Put newest emails on top
         rsort($imapEmails);
         foreach ($imapEmails as $Email) {
             //Loop through each email and return the content
             $email_overview = imap_fetch_overview($imapResource, $Email, 0);
             if (strtotime(reset($email_overview)->date) < $channel->lastSuccess) {
                 continue;
             }
             $email_header_info = imap_header($imapResource, $Email);
             $email_message = imap_fetchbody($imapResource, $Email, 1);
             $source_name = \reset($email_overview)->from;
             $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name);
             $source->name = $source_name;
             $source->parent = $channel->id;
             $source->type = $channel->type;
             $source->subType = $channel->subType;
             $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
             $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $email_overview[0]->subject, array($email_message));
             //the message
             $item->link = null;
             $item->date = $email_header_info->udate;
             $contentItems[] = $item;
         }
     }
     imap_close($imapResource);
     return $contentItems;
 }
开发者ID:Bridgeborn,项目名称:Swiftriver,代码行数:45,代码来源:IMAPParser.php


示例17: getPart

 function getPart($partNumber, $encoding)
 {
     $data = imap_fetchbody($this->connection, $this->messageNumber, $partNumber, FT_UID);
     switch ($encoding) {
         case 0:
             return $data;
             // 7BIT
         // 7BIT
         case 1:
             return $data;
             // 8BIT
         // 8BIT
         case 2:
             return $data;
             // BINARY
         // BINARY
         case 3:
             return base64_decode($data);
             // BASE64
         // BASE64
         case 4:
             return quoted_printable_decode($data);
             // QUOTED_PRINTABLE
         // QUOTED_PRINTABLE
         case 5:
             return $data;
             // OTHER
     }
 }
开发者ID:Chendri,项目名称:phpemailclient,代码行数:29,代码来源:EmailMessage.php


示例18: fetchbody

 function fetchbody($stream, $msgnr, $partnr, $flags = 0)
 {
     // do we force use of msg UID's
     if ($this->force_msg_uids == True && !($flags & FT_UID)) {
         $flags |= FT_UID;
     }
     return imap_fetchbody($stream, $msgnr, $partnr, $flags);
 }
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:8,代码来源:class.mail_dcom_pop3.inc.php


示例19: fetchContent

	private function fetchContent( Message $message , $subtype , $msgNum , $part , array $parameters = array() ) {
		$content = base64_decode( imap_fetchbody( ImapState::$resource , $msgNum , $part ) );

		foreach ( $parameters as $parameter ) {
			if ( $parameter->attribute == 'CHARSET' ) {
				$content = mb_convert_encoding( $content , 'UTF-8' , $parameter->value );
			}
		}

		$message->setContent( $subtype , $content );
	}
开发者ID:netojoaobatista,项目名称:phpmail,代码行数:11,代码来源:ImapOpenedState.php


示例20: CheckMail

function CheckMail()
{
    echo "===========================\n";
    echo " CHECK MAIL\n";
    echo "===========================\n";
    global $rawDIR, $nowGradeFile, $now;
    // 	$outFile=fopen($nowGradeFile,"w");
    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
    $username = "{$emailMine}";
    $password = 'WRONG_PASS';
    /* try to connect */
    $inbox = imap_open($hostname, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error());
    /* grab emails */
    // 	$emails = imap_search($inbox, 'ALL', '[email protected]');
    $emails = imap_search($inbox, 'FROM [email protected]');
    /* if emails are returned, cycle through each... */
    if ($emails) {
        /* begin output var */
        $output = '';
        /* put the newest emails on top */
        // 		rsort($emails);
        /* for every email... */
        foreach ($emails as $email_number) {
            /* get information specific to this email */
            $overview = imap_fetch_overview($inbox, $email_number, 0);
            // 			if ( $overview[0]->from == "[email protected]" && $overview[0]->seen == 0 ) {
            // 			if ( $overview[0]->from == "[email protected]" ) {
            $output .= "Number: {$email_number}\n";
            $output .= "From: " . $overview[0]->from . "\n";
            $output .= "Subject: " . $overview[0]->subject . "\n";
            $output .= "Seen: " . $overview[0]->seen . "\n";
            $output .= "Date: " . $overview[0]->date . "\n";
            $message = imap_fetchbody($inbox, $email_number, 1);
            // 				$message = imap_body($inbox, $email_number, 'FT_PEEK');
            // 				echo "MESSAGE: ". $message;
            $outFile = fopen($nowGradeFile, "w");
            fwrite($outFile, $message);
            fclose($outFile);
            if (file_exists($nowGradeFile)) {
                echo "Wrote {$nowGradeFile}.\n";
            } else {
                echo "Failed to write {$nowGradeFile}.\n";
            }
            // 				imap_setflag_full($inbox, $email_number, 'unseen');
            // 				imap_mail_move($inbox, "$email_number", 'School');
            // 				break;
            // 			}
        }
    }
    /* close the connection */
    imap_close($inbox);
    echo "{$output}\n";
    exit;
}
开发者ID:mpalermo73,项目名称:scripts-git,代码行数:54,代码来源:Grades.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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