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

PHP imap_bodystruct函数代码示例

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

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



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

示例1: getAttachments

function getAttachments($imap, $mailNum, $part, $partNum)
{
    $attachments = array();
    if (isset($part->parts)) {
        foreach ($part->parts as $key => $subpart) {
            if ($partNum != "") {
                $newPartNum = $partNum . "." . ($key + 1);
            } else {
                $newPartNum = $key + 1;
            }
            $result = getAttachments($imap, $mailNum, $subpart, $newPartNum);
            if (count($result) != 0) {
                array_push($attachments, $result);
            }
        }
    } else {
        if (isset($part->disposition)) {
            if ($part->disposition == "ATTACHMENT") {
                $partStruct = imap_bodystruct($imap, $mailNum, $partNum);
                $attachmentDetails = array("name" => $part->dparameters[0]->value, "partNum" => $partNum, "enc" => $partStruct->encoding);
                return $attachmentDetails;
            }
        }
    }
    return $attachments;
}
开发者ID:vsanth,项目名称:yii-customer-database,代码行数:26,代码来源:mailbox_orig.php


示例2: getMessageBodyStruct

 /**
  * Get body structure
  * 
  * @return mixed
  */
 public function getMessageBodyStruct($pos, $no, $uid = 0)
 {
     return imap_bodystruct($this->_mailbox_link, $pos, $no, $uid);
 }
开发者ID:Rikisha,项目名称:proj,代码行数:9,代码来源:lib.php


示例3: getBodystruct

 public function getBodystruct($uid, $part)
 {
     return $this->bodystruct = imap_bodystruct($this->mbox, $this->getMsgno($uid), $part);
 }
开发者ID:skrokbogumil,项目名称:KlientPoczty,代码行数:4,代码来源:mailService.php


示例4: setRawBody

 /**
  * This function returns an object containing the raw headers of the message.
  *
  * @param  string $partIdentifier
  * @return string
  */
 protected function setRawBody($partIdentifier = null)
 {
     if (isset($partIdentifier)) {
         $body = imap_fetchbody($this->imapStream, $this->uid, $partIdentifier, FT_UID | FT_PEEK);
         $this->rawBody[$partIdentifier] = ['structure' => imap_bodystruct($this->imapStream, imap_msgno($this->imapStream, $this->uid), $partIdentifier), 'body' => $body];
     } else {
         $this->rawBody = $body = imap_body($this->imapStream, $this->uid, FT_UID | FT_PEEK);
     }
     return $body;
 }
开发者ID:apexwire,项目名称:fetch,代码行数:16,代码来源:Message.php


示例5: Exception

    throw new Exception($err);
}
$emails = imap_search($inbox, 'ALL UNSEEN');
if (!$emails) {
    return;
}
foreach ($emails as $msg_number) {
    $header = imap_headerinfo($inbox, $msg_number);
    $structure = imap_fetchstructure($inbox, $msg_number);
    $text = "";
    $attachments = array();
    // Use text from non-multipart messages directly
    if (empty($structure->parts)) {
        // Get message body
        $text = imap_fetchbody($inbox, $msg_number, 1);
        $part = imap_bodystruct($inbox, $msg_number, 1);
        // Decode body
        if ($part->encoding == 4) {
            $text = imap_qprint($text);
        } elseif ($part->encoding == 3) {
            $text = imap_base64($text);
        }
    }
    // Load message parts for multipart messages
    if (!empty($structure->parts)) {
        foreach ($structure->parts as $part_number => $part) {
            // Handle plaintext
            if ($part->type === 0 && !trim($text)) {
                $text = imap_fetchbody($inbox, $msg_number, $part_number + 1);
                // Decode body
                if ($part->encoding == 4) {
开发者ID:Rayne,项目名称:phproject,代码行数:31,代码来源:checkmail2.php


示例6: saveAttachment

 function saveAttachment($uid, $partNum, $encoding)
 {
     $partStruct = imap_bodystruct($this->stream, imap_msgno($this->stream, $uid), $partNum);
     $message = imap_fetchbody($this->stream, $uid, $partNum, FT_UID);
     switch ($encoding) {
         case 0:
         case 1:
             $message = imap_8bit($message);
             break;
         case 2:
             $message = imap_binary($message);
             break;
         case 3:
             $message = imap_base64($message);
             break;
         case 4:
             $message = quoted_printable_decode($message);
             break;
     }
     return $message;
 }
开发者ID:kam1katze,项目名称:ocDashboard,代码行数:21,代码来源:imap.php


示例7: imap_fetchstructure

 } else {
     if ($headrs->deleted) {
         $delstyle = " text-decoration:line-through;opacity:.35; ";
     } else {
         $delstyle = "";
     }
 }
 $mail_headerinfo = @imap_headerinfo($mbox, $headrs->msgno);
 $mail_senddate = $mail_headerinfo->MailDate;
 $mailstruct = imap_fetchstructure($mbox, $headrs->msgno);
 $selectBoxDisplay = "";
 $att = "";
 $contentParts = count($mailstruct->parts);
 if ($contentParts >= 2) {
     for ($i = 2; $i <= $contentParts; $i++) {
         $att[$i - 2] = imap_bodystruct($mbox, $headrs->msgno, $i);
     }
     for ($k = 0; $k < sizeof($att); $k++) {
         $p = $att[$k];
         if (count($p->dparameters) > 0) {
             foreach ($p->dparameters as $dparam) {
                 if (strtoupper($dparam->attribute) == 'NAME' || strtoupper($dparam->attribute) == 'FILENAME') {
                     $selectBoxDisplay[$k] = $dparam->value;
                 }
             }
         }
         //if no filename found
         if ($filename == '') {
             // if there are any parameters present in this part
             if (count($p->parameters) > 0) {
                 foreach ($p->parameters as $param) {
开发者ID:brondsem,项目名称:imobmail,代码行数:31,代码来源:folderlist.php


示例8: str_replace

{$body}


</div></li>
END;
} else {
    $body = str_replace('<a ', "<a target=\"_blank\" ", $body);
    $body = str_replace('<A ', "<a target=\"_blank\" ", $body);
    echo $body;
}
$struct = imap_fetchstructure($mbox, $msgno);
$contentParts = count($struct->parts);
if ($contentParts >= 2) {
    for ($i = 2; $i <= $contentParts; $i++) {
        $att[$i - 2] = imap_bodystruct($mbox, $msgno, $i);
    }
    for ($k = 0; $k < sizeof($att); $k++) {
        /*if ($att[$k]->parameters[0]->value == "us-ascii" || $att[$k]->parameters[0]->value    == "US-ASCII") {
        		if ($att[$k]->parameters[1]->value != "") {
        		$selectBoxDisplay[$k] = imap_utf8_workaround($att[$k]->parameters[1]->value);
        		}
        		} elseif ($att[$k]->parameters[0]->value != "iso-8859-1" &&    $att[$k]->parameters[0]->value != "ISO-8859-1") {
        		$selectBoxDisplay[$k] = imap_utf8_workaround($att[$k]->parameters[0]->value);
        		}*/
        $p = $att[$k];
        if (count($p->dparameters) > 0) {
            foreach ($p->dparameters as $dparam) {
                if (strtoupper($dparam->attribute) == 'NAME' || strtoupper($dparam->attribute) == 'FILENAME') {
                    $selectBoxDisplay[$k] = $dparam->value;
                }
开发者ID:brondsem,项目名称:imobmail,代码行数:30,代码来源:details.php


示例9: getBodyPart

 /**
  * Retrieve body part, and if it's file write it to filesystem
  *
  * @param integer $message_id
  * @param string $body_part
  * @param string $file_path
  * @return mixed
  */
 function getBodyPart($message_id, $body_part, $encoding, $file_path = false)
 {
     if ($file_path) {
         if (!MM_CAN_DOWNLOAD_LARGE_ATTACHMENTS) {
             $structure = imap_bodystruct($this->getConnection(), $message_id, $body_part);
             if (!instance_of($structure, 'stdClass')) {
                 return false;
             }
             // if
             // if attachment is larger than FAIL_SAFE_IMAP_ATTACHMENT_SIZE_MAX, don't download it
             if ($structure->bytes > FAIL_SAFE_IMAP_ATTACHMENT_SIZE_MAX) {
                 return false;
             }
             // if
         }
         // if
         $savebody_result = imap_savebody_alt($this->getConnection(), $file_path, $message_id, $body_part);
         if (!$savebody_result) {
             return false;
         }
         // if
         $temporary_file = $file_path . '_temp';
         switch ($encoding) {
             case 'base64':
                 $decoding_result = base64_decode_file($file_path, $temporary_file);
                 if ($decoding_result) {
                     @unlink($file_path);
                     rename($temporary_file, $file_path);
                     return true;
                 } else {
                     @unlink($file_path);
                     @unlink($temporary_file);
                     return false;
                 }
                 break;
             case 'quoted-printable':
                 $decoding_result = quoted_printable_decode_file($file_path, $temporary_file);
                 if ($decoding_result) {
                     @unlink($file_path);
                     rename($temporary_file, $file_path);
                     return true;
                 } else {
                     @unlink($file_path);
                     @unlink($temporary_file);
                     return false;
                 }
                 break;
         }
         // switch
         return true;
     } else {
         $result = imap_fetchbody($this->getConnection(), $message_id, $body_part);
         switch ($encoding) {
             case 'base64':
                 return imap_base64($result);
                 break;
             case 'quoted-printable':
                 return imap_qprint($result);
                 break;
             default:
                 return $result;
                 break;
         }
         // switch
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:75,代码来源:PHPImapMailboxManager.class.php


示例10: getInlineAttach

 function getInlineAttach($partNum, $encoding)
 {
     $this->structure = @imap_bodystruct($this->paloImap, @imap_msgno($this->paloImap, $this->uid), $partNum);
     $filename = $this->structure->dparameters[0]->value;
     $message = @imap_fetchbody($this->paloImap, $this->uid, $partNum, FT_UID);
     $message = $this->decodeAttachData($encoding, $message);
     header("Content-Type: application/octet-stream");
     header("Content-Disposition: inline; filename=" . $filename);
     echo $message;
 }
开发者ID:lordbasex,项目名称:elastix-gui,代码行数:10,代码来源:paloSantoHome.class.php


示例11: processBounce

 function processBounce($pos, $type, $header = null)
 {
     if (!empty($header)) {
         $md5header = md5($header);
     } else {
         $md5header = null;
     }
     if ($type == 'DSN') {
         // first part of DSN (Delivery Status Notification), human-readable explanation
         $dsn_msg = imap_fetchbody($this->_mailbox_link, $pos, "1");
         $dsn_msg_structure = imap_bodystruct($this->_mailbox_link, $pos, "1");
         if ($dsn_msg_structure->encoding == 3) {
             $dsn_msg = base64_decode($dsn_msg);
         }
         // second part of DSN (Delivery Status Notification), delivery-status
         $dsn_report = imap_fetchbody($this->_mailbox_link, $pos, "2");
         // process bounces by rules
         $result = bmhDSNRules($dsn_msg, $dsn_report, $this->debug_dsn_rule);
     } elseif ($type == 'BODY') {
         $structure = imap_fetchstructure($this->_mailbox_link, $pos);
         switch ($structure->type) {
             case 0:
                 // Content-type = text
             // Content-type = text
             case 2:
                 // Content-type = message
                 $body = imap_body($this->_mailbox_link, $pos);
                 if ($structure->encoding == 3) {
                     $body = base64_decode($body);
                 }
                 $body = substr($body, 0, 1000);
                 $result = bmhBodyRules($body, $structure, $this->debug_body_rule);
                 break;
             case 1:
                 // Content-type = multipart
                 $body = imap_fetchbody($this->_mailbox_link, $pos, "1");
                 // TRICKY : detect encoding and decode
                 // only handle base64 right now
                 if ($structure->parts[0]->encoding == 3) {
                     $body = base64_decode($body);
                 }
                 $body = substr($body, 0, 1000);
                 $result = bmhBodyRules($body, $structure, $this->debug_body_rule);
                 break;
             default:
                 // unsupport Content-type
                 $this->output("The No. {$pos} is unsupport Content-Type:{$structure->type}", VERBOSE_REPORT);
                 return false;
         }
     } else {
         // internal error
         $this->error_msg = 'Internal Error: unknown type';
         return false;
     }
     $result['rule_type'] = $type;
     if (!empty($header)) {
         if (preg_match("/Subject:((?:[^\n]|\n[\t ])+)(?:\n[^\t ]|\$)/is", $header, $match)) {
             $result['subject'] = trim($match[1]);
         }
         if (preg_match("/Date:[\t ]*(.*)/i", $header, $match)) {
             $result['date'] = trim($match[1]);
         }
         if (preg_match("/From:((?:[^\n]|\n[\t ])+)(?:\n[^\t ]|\$)/is", $header, $match)) {
             $addresses = imap_rfc822_parse_adrlist($match[1], '???');
             if (!empty($addresses) && is_array($addresses)) {
                 $result['from'] = $addresses[0]->mailbox . '@' . $addresses[0]->host;
             }
         }
     }
     // last chance for unmatched rules
     if ($result['rule_no'] == '0000') {
         $result = bmhOtherRules($result);
     }
     $result['md5header'] = $md5header;
     // log the result if wanted
     if (!empty($this->log_function) && function_exists($this->log_function)) {
         call_user_func($this->log_function, $result);
         $this->c_log++;
     }
     // call user function for unmatched rules
     if ($result['rule_no'] == '0000') {
         if (!empty($this->unmatched_function) && function_exists($this->unmatched_function)) {
             return call_user_func($this->unmatched_function, $result);
         }
         return false;
     }
     if ($this->testmode) {
         $this->output(print_r($result, true));
         return false;
     }
     // match a rule, take bounce action
     if (!empty($this->action_function) && function_exists($this->action_function)) {
         return call_user_func($this->action_function, $result);
     }
     return true;
 }
开发者ID:beeksiwaais,项目名称:massmailer,代码行数:96,代码来源:bmh.php


示例12: getMessagePart

 public function getMessagePart($msgno, $partObj, $partno = 0)
 {
     echo "<br /><hr /><br />getMessagePart({$msgno},part,{$partno})<br />";
     // If partno is 0 then fetch body as a single part message
     //echo " imap_fetchbody($this->hconnection, $msgno, $partno, FT_PEEK); ";
     // echo "<hr /> partno=";//.(int)$partno." ";
     // var_dump($partno);
     // echo "<br /> msgno=".(int)$msgno." ";
     // var_dump($msgno);
     if ($partno) {
         $data = imap_fetchbody($this->hconnection, $msgno, $partno, FT_PEEK);
     } else {
         $data = imap_body($this->hconnection, $msgno, FT_PEEK);
     }
     // $data = ($partno) ? imap_fetchbody($conn, $messageId, $partno) : imap_body($conn, $messageId);
     // Any part may be encoded, even plain text messages, so decoding it
     echo " encoding " . $partObj->encoding . "\n";
     if ($partObj->encoding == 4) {
         $data = quoted_printable_decode($data);
     } elseif ($partObj->encoding == 3) {
         $data = base64_decode($data);
     }
     // Collection all parameters, like name, filenames of attachments, etc.
     $params = array();
     if ($partObj->parameters) {
         foreach ((array) $partObj->parameters as $x) {
             echo " attribute " . $x->attribute . "\n";
             $params[strtolower($x->attribute)] = $x->value;
             if ($x->attribute == 'charset' || $x->attribute == 'CHARSET') {
                 echo " charset " . $x->value . "\n";
                 if (in_array(strtolower($x->value), array('windows-1250', 'iso-8859-2'))) {
                     echo '[BODY : ENCODING] presented: ' . $x->value . ' => encoding to utf-8' . "\n";
                     $data = iconv($x->value, 'UTF-8', $data);
                 }
                 if (in_array(strtolower($x->value), array('us-ascii', 'default'))) {
                     require_once LIB_PATH . 'mail/Mail_Encoding.php';
                     $detected = Mail_Encoding::detect($data);
                     if ($detected != 'utf-8') {
                         echo '[BODY : ENCODING] presented: ' . $x->value . ' , detected: ' . $detected . ' => encoding to utf-8' . "\n";
                         $data = iconv($detected, 'UTF-8', $data);
                     }
                 }
             }
         }
     }
     if ($partObj->dparameters) {
         foreach ((array) $partObj->dparameters as $x) {
             $params[strtolower($x->attribute)] = $x->value;
         }
     }
     if ($partObj->id) {
         if ($partObj->type == 5) {
             // IMAGE
             $extension = strtolower($partObj->subtype);
             $params['filename'] = md5($partObj->id) . '.' . $extension;
         }
     }
     // Any part with a filename is an attachment,
     if ($params['filename'] || $params['name']) {
         // Filename may be given as 'Filename' or 'Name' or both
         $filename = $params['filename'] ? $params['filename'] : $params['name'];
         if (empty($this->attachments[$filename])) {
             $this->attachments[$filename] = $data;
         }
     }
     // Processing plain text message
     if ($partObj->type == 0 && $data) {
         // Messages may be split in different parts because of inline attachments,
         // so append parts together with blank row.
         if (strtolower($partObj->subtype) == 'plain' || strtolower($partObj->subtype) == 'text/plain') {
             $this->plainBody = trim($data);
             // echo "<br /><br /><br /><hr /><br />PLAINBODY<br />$data<br />ENDPLAINBODY<hr /><br />";
         } else {
             $this->htmlBody = $data;
             // echo "<br /><br /><br /><hr /><br />HTMLBODY<br />$data<br />ENDHTMLBODY<hr /><br />";
         }
     } elseif ($partObj->type == 2 && $data) {
         $this->plainBody .= $data;
     }
     // Here is recursive call for subpart of the message
     if ($partObj->parts) {
         foreach ((array) $partObj->parts as $partno2 => $part2) {
             $this->getMessagePart($msgno, $part2, $partno . '.' . ($partno2 + 1));
         }
         if ($partObj->subtype == 'RFC822') {
             echo '[RFC PART] detected: ' . $partno . "\n";
             for ($i = sizeof($partObj->parts) + 1;; $i++) {
                 $partObj2 = imap_bodystruct($this->hconnection, $msgno, $partno . '.' . $i);
                 if (!empty($partObj2)) {
                     $this->getMessagePart($msgno, $partObj2, $partno . '.' . $i);
                 } else {
                     break;
                 }
             }
         }
     }
 }
开发者ID:rafaldrive,项目名称:ucaps,代码行数:97,代码来源:mailbox.class.php


示例13: returnBodyStructureObj

 /**
  * returnMessageBodyStructureObj
  * @see http://www.php.net/manual/en/function.imap-bodystruct.php
  * @param $messageNumber(int),part(int)
  * @return object
  */
 private function returnBodyStructureObj($messageNumber, $part)
 {
     return imap_bodystruct($this->stream, $messageNumber, $part);
 }
开发者ID:hiveclick,项目名称:mojavi,代码行数:10,代码来源:Imap.php


示例14: exit

    exit("TEST FAILED: Unable to create test mailbox\n");
}
echo "\nGet and validate structure of body part 1\n";
$m = imap_bodystruct($imap_stream, 1, "1");
$mandatoryFields = array('ifsubtype', 'ifdescription', 'ifid', 'ifdisposition', 'ifdparameters', 'ifparameters');
foreach ($mandatoryFields as $mf) {
    if (isValid($m->{$mf})) {
        echo "{$mf} is 0 or 1\n";
    } else {
        echo "{$mf} FAIL\n";
    }
}
if (is_array($m->parameters)) {
    echo "parameters is an array\n";
}
echo "\nTry to get part 4!\n";
var_dump(imap_bodystruct($imap_stream, 1, "4"));
imap_close($imap_stream);
function isValid($param)
{
    if ($param == 0 || $param == 1) {
        $result = true;
    } else {
        $result = false;
    }
    return $result;
}
?>
===Done===
<?php 
require_once 'clean.inc';
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:imap_bodystruct_basic.php


示例15: GetAttachments

 /**
  * Returns an array containing all files attached to message
  *
  * @param int $msgno The index of the message to retrieve
  * @param bool $include_raw_data The raw data is the actual contents of the attachment file.  Setting this to FALSE will allow you to display the name, size, type, etc of all attachments without actually downloading the contents of the files.  Use GetAttachmentRawData to retrieve the raw data for an individual attachment.
  * @return array An array of attachments
  *
  */
 function GetAttachments($msgno, $include_raw_data = true)
 {
     $struct = imap_fetchstructure($this->mbox, $msgno);
     $contentParts = count($struct->parts);
     $attachments = array();
     if ($contentParts >= 2) {
         for ($i = 2; $i <= $contentParts; $i++) {
             $att[$i - 2] = imap_bodystruct($this->mbox, $msgno, $i);
             // these extra bits help us later...
             $att[$i - 2]->x_msg_id = $msgno;
             $att[$i - 2]->x_part_id = $i;
         }
         for ($k = 0; $k < sizeof($att); $k++) {
             if (strtolower($att[$k]->parameters[0]->value) == "us-ascii" && $att[$k]->parameters[1]->value != "") {
                 $attachments[$k] = $this->_getPartFromStruct($att[$k], $include_raw_data);
             } elseif (strtolower($att[$k]->parameters[0]->value) != "iso-8859-1") {
                 $attachments[$k] = $this->_getPartFromStruct($att[$k], $include_raw_data);
             }
         }
     }
     return $attachments;
 }
开发者ID:hpazevedo,项目名称:Teste-BDR,代码行数:30,代码来源:Pop3Client.php


示例16: email_to_commsy


//.........这里部分代码省略.........
        $user = $user_list->getfirst();
        $found_users = array();
        while ($user) {
            if ($account != '') {
                if ($account == $user->getUserID()) {
                    $found_users[] = $user;
                }
            } else {
                $found_users[] = $user;
            }
            $user = $user_list->getnext();
        }
        foreach ($found_users as $found_user) {
            $private_room_user = $found_user->getRelatedPrivateRoomUserItem();
            $private_room = $private_room_user->getOwnRoom();
            $translator->setSelectedLanguage($private_room->getLanguage());
            if ($private_room->getEmailToCommSy()) {
                $email_to_commsy_secret = $private_room->getEmailToCommSySecret();
                $result_mail = new cs_mail();
                $result_mail->set_to($sender);
                $result_mail->set_from_name('CommSy');
                // $result_mail->set_from_email('[email protected]');
                $errors = array();
                if ($secret == $email_to_commsy_secret) {
                    $private_room_id = $private_room->getItemID();
                    $files = array();
                    if ($struct->subtype == 'PLAIN') {
                    } else {
                        if ($struct->subtype == 'MIXED') {
                            // with attachment
                            $contentParts = count($struct->parts);
                            if ($contentParts >= 2) {
                                for ($i = 2; $i <= $contentParts; $i++) {
                                    $att[$i - 2] = imap_bodystruct($mbox, $msgno, $i);
                                }
                                for ($k = 0; $k < sizeof($att); $k++) {
                                    $strFileName = $att[$k]->dparameters[0]->value;
                                    $strFileType = strrev(substr(strrev($strFileName), 0, 4));
                                    $fileContent = imap_fetchbody($mbox, $msgno, $k + 2);
                                    $file = getFile($strFileType, $strFileName, $fileContent);
                                    // copy file to temp
                                    $temp_file = 'var/temp/' . $strFileName . '_' . getCurrentDateTimeInMySQL();
                                    file_put_contents($temp_file, $file);
                                    $temp_array = array();
                                    $temp_array['name'] = utf8_encode($strFileName);
                                    $temp_array['tmp_name'] = $temp_file;
                                    $temp_array['file_id'] = $temp_array['name'] . '_' . getCurrentDateTimeInMySQL();
                                    $temp_array['file_size'] = filesize($temp_file);
                                    $files[] = $temp_array;
                                }
                            }
                        }
                    }
                    $environment->setCurrentContextID($private_room_id);
                    $environment->setCurrentUser($private_room_user);
                    $environment->unsetLinkModifierItemManager();
                    $material_manager = $environment->getMaterialManager();
                    $material_item = $material_manager->getNewItem();
                    $material_item->setTitle(trim(str_replace($email_to_commsy_secret . ':', '', $subject)));
                    $material_item->setDescription($body);
                    // attach files to the material
                    $file_manager = $environment->getFileManager();
                    $file_manager->setContextLimit($private_room_id);
                    $portal_item = $environment->getCurrentPortalItem();
                    $portal_max_file_size = $portal_item->getMaxUploadSizeInBytes();
                    $file_id_array = array();
开发者ID:a2call,项目名称:commsy,代码行数:67,代码来源:cron_email_upload.php


示例17: email_piping

 /**
  * Start the email retrieval
  *
  * @param int $id email_setup.id 
  */
 function email_piping($id)
 {
     global $C_debug;
     # check for imap support:
     if (!is_callable('imap_open')) {
         $C_debug->error('core::email_piping', 'email_piping()', 'imap_open() - not supported');
         return;
     }
     $db =& DB();
     $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'setup_email WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND id = ' . $db->qstr($id);
     $result = $db->Execute($sql);
     if ($result && $result->RecordCount()) {
         $this->cfg = $result->fields;
         $this->delete_action = $this->cfg['piping_action'];
         $type = $this->cfg['piping'];
         // imap/pop
         // get imap_open connection string
         $constr = $this->get_connection_string($type, $this->cfg['piping_host']);
         // attempt connection
         error_reporting(0);
         @($mbox = imap_open($constr, $this->cfg['piping_username'], $this->cfg['piping_password']));
         // attempt alternate conneciton
         if (!$mbox) {
             $constr = $this->get_connection_string($type + 2, $this->cfg['piping_host']);
             @($mbox = imap_open($constr, $this->cfg['piping_username'], $this->cfg['piping_password']));
         }
         // error log
         if (!$mbox) {
             $C_debug->error('core::email_piping', 'email_piping()', imap_last_error() . ' -- ' . $constr);
             return false;
         }
         // check for messages
         if (@($hdr = imap_check($mbox))) {
             $msgCount = $hdr->Nmsgs;
             if ($msgCount == 0) {
                 return false;
             }
         } else {
             return false;
             // no messages
         }
         // get folder overview
         @($overview = imap_fetch_overview($mbox, "1:{$msgCount}", 0));
         $size = sizeof($overview);
         // loop through messages
         for ($i = $size - 1; $i >= 0; $i--) {
             $val = $overview[$i];
             $msg = $val->msgno;
             $this->attachments[$msg] = false;
             // formatting for from e-mail address
             $from = $val->from;
             $sender = $from = $val->from;
             $from = preg_replace("/\"/", "", $from);
             if (preg_match("/</", $from)) {
                 $f = explode("<", $from);
                 $sender = $f[0];
                 $from = $f[1];
                 $from = str_replace(">", "", $from);
             }
             // retrieve body
             $body = $this->get_part($mbox, $msg, "TEXT/PLAIN");
             if (empty($body)) {
                 $body = $this->get_part($mbox, $msg, "TEXT/HTML");
                 if (!empty($body)) {
                     $body = str_replace("<br>", "\r\n", $body);
                 }
             }
             // get attachements
             if ($this->get_attachments) {
                 $struct = imap_fetchstructure($mbox, $msg);
                 $contentParts = count($struct->parts);
                 if ($contentParts >= 2) {
                     for ($ii = 2; $ii <= $contentParts; $ii++) {
                         $c = $ii - 2;
                         $att[$c] = imap_bodystruct($mbox, $msg, $ii);
                     }
                     // download tmp file and add to attachemnt array
                     for ($k = 0; $k < sizeof($att); $k++) {
                         $tmp = $this->download_file($mbox, $msg, $k, $att[$k]->parameters[0]->value);
                     }
                 }
             }
             // Set the result array:
             $this->results[] = array('uniqueId' => $val->message_id, 'date' => $val->date, 'from' => trim($from), 'to' => $val->to, 'sender' => trim($sender), 'subject' => trim($val->subject), 'body' => trim($body), 'attach' => $this->attachments[$msg]);
             // mark for deletion or move
             if ($this->cfg['piping_action'] == 1) {
                 if ($this->delete_action) {
                     imap_delete($mbox, $msg);
                 } else {
                     if (($type == 2 || $type == 4) && !empty($this->move_mbox)) {
                         imap_mail_move($mbox, $msg, $this->move_mbox);
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:101,代码来源:email_piping.inc.php


示例18: processDsn

 protected function processDsn($messageId)
 {
     $result = array('email' => null, 'bounceType' => self::BOUNCE_HARD, 'action' => null, 'statusCode' => null, 'diagnosticCode' => null);
     $action = $statusCode = $diagnosticCode = null;
     // first part of DSN (Delivery Status Notification), human-readable explanation
     $dsnMessage = imap_fetchbody($this->_connection, $messageId, "1");
     $dsnMessageStructure = imap_bodystruct($this->_connection, $messageId, "1");
     if ($dsnMessageStructure->encoding == 4) {
         $dsnMessage = quoted_printable_decode($dsnMessage);
     } elseif ($dsnMessageStructure->encoding == 3) {
         $dsnMessage = base64_decode($dsnMessage);
     }
     // second part of DSN (Delivery Status Notification), delivery-status
     $dsnReport = imap_fetchbody($this->_connection, $messageId, "2");
     if (preg_match("/Original-Recipient: rfc822;(.*)/i", $dsnReport, $matches)) {
         $emailArr = imap_rfc822_parse_adrlist($matches[1], 'default.domain.name');
         if (isset($emailArr[0]->host) && $emailArr[0]->host != '.SYNTAX-ERROR.' && $emailArr[0]->host != 'default.domain.name') {
             $result['email'] = $emailArr[0]->mailbox . '@' . $emailArr[0]->host;
         }
     } else {
         if (preg_match("/Final-Recipient: rfc822;(.*)/i", $dsnReport, $matches)) {
             $emailArr = imap_rfc822_parse_adrlist($matches[1], 'default.domain.name');
             if (isset($emailArr[0]->host) && $emailArr[0]->host != '.SYNTAX-ERROR.' && $emailArr[0]->host != 'default.domain.name') {
                 $result['email'] = $emailArr[0]->mailbox . '@' . $emailArr[0]->host;
             }
         }
     }
     if (preg_match("/Action: (.+)/i", $dsnReport, $matches)) {
         $action = strtolower(trim($matches[1]));
     }
     if (preg_match("/Status: ([0-9\\.]+)/i", $dsnReport, $matches)) {
         $statusCode = $matches[1];
     }
     // Could be multi-line , if the new line is beginning with SPACE or HTAB
     if (preg_match("/Diagnostic-Code:((?:[^\n]|\n[\t ])+)(?:\n[^\t ]|\$)/is", $dsnReport, $matches)) {
         $diagnosticCode = $matches[1];
     }
     if (empty($result['email'])) {
         if (preg_match("/quota exceed.*<(\\S+@\\S+\\w)>/is", $dsnMessage, $matches)) {
             $result['email'] = $matches[1];
             $result['bounceType'] = self::BOUNCE_SOFT;
         }
     } else {
         // "failed" / "delayed" / "delivered" / "relayed" / "expanded"
         if ($action == 'failed') {
             $rules = $this->getRules();
             $foundMatch = false;
             foreach ($rules[self::DIAGNOSTIC_CODE_RULES] as $rule) {
                 if (preg_match($rule['regex'], $diagnosticCode, $matches)) {
                     $foundMatch = true;
                     $result['bounceType'] = $rule['bounceType'];
                     break;
                 }
             }
             if (!$foundMatch) {
                 foreach ($rules[self::DSN_MESSAGE_RULES] as $rule) {
                     if (preg_match($rule['regex'], $dsnMessage, $matches)) {
                         $foundMatch = true;
                         $result['bounceType'] = $rule['bounceType'];
                         break;
                     }
                 }
             }
             if (!$foundMatch) {
                 foreach ($rules[self::COMMON_RULES] as $rule) {
                     if (preg_match($rule['regex'], $dsnMessage, $matches)) {
                         $foundMatch = true;
                         $result['bounceType'] = $rule['bounceType'];
                         break;
                     }
                 }
             }
             if (!$foundMatch) {
                 $result['bounceType'] = self::BOUNCE_HARD;
             }
         } else {
             $result['bounceType'] = self::BOUNCE_SOFT;
         }
     }
     $result['action'] = $action;
     $result['statusCode'] = $statusCode;
     $result['diagnosticCode'] = $diagnosticCode;
     return $result;
 }
开发者ID:schpill,项目名称:thin,代码行数:84,代码来源:Bounce.php


示例19: processBounce

 /**
  * Function to process each individual message
  * @param int    $pos            (message number)
  * @param string $type           (DNS or BODY type)
  * @param string $totalFetched   (total number of messages in mailbox)
  * @return boolean
  */
 function processBounce($pos, $type, $totalFetched)
 {
     $header = imap_header($this->_mailbox_link, $pos);
     $subject = strip_tags($header->subject);
     $met = ini_get('max_execution_time');
     if ($met < 6000 && $met != 0) {
         set_time_limit(6000);
     }
     imap_timeout(IMAP_READTIMEOUT, 6000);
     imap_timeout(IMAP_WRITETIMEOUT, 6000);
     if ($type == 'DSN') {
         // first part of DSN (Delivery Status Notification), human-readable explanation
         $dsn_msg = imap_fetchbody($this->_mailbox_link, $pos, "1");
         $dsn_msg_structure = imap_bodystruct($this->_mailbox_link, $pos, "1");
         if ($dsn_msg_structure->encoding == 4) {
             $dsn_msg = quoted_printable_decode($dsn_msg);
         } elseif ($dsn_msg_structure->encoding == 3) {
             $dsn_msg = base64_decode($dsn_msg);
         }
         // second part of DSN (Delivery Status Notification), delivery-status
         $dsn_report = imap_fetchbody($this->_mailbox_link, $pos, "2");
         // process bounces by rules
         $result = bmhDSNRules($dsn_msg, $dsn_report, $this->debug_dsn_rule);
     } elseif ($type == 'BODY') {
         $structure = imap_fetchstructure($this->_mailbox_link, $pos);
         switch ($structure->type) {
             case 0:
                 // Content-type = text
             // Content-type = text
             case 1:
                 // Content-type = multipart
                 $body = imap_fetchbody($this->_mailbox_link, $pos, "1");
                 // Detect encoding and decode - only base64
                 if (!empty($structure->parts[0]->encoding) && $structure->parts[0]->encoding == 4) {
                     $body = quoted_printable_decode($body);
                 } elseif (!empty($structure->parts[0]->encoding) && $structure->parts[0]->encoding == 3) {
                     $body = base64_decode($body);
                 }
                 $result = bmhBodyRules($body, $structure, $this->debug_body_rule);
                 break;
             case 2:
                 // Content-type = message
                 $body = imap_body($this->_mailbox_link, $pos);
                 if ($structure->encoding == 4) {
                     $body = quoted_printable_decode($body);
                 } elseif ($structure->encoding == 3) {
                     $body = base64_decode($body);
                 }
                 $body = substr($body, 0, 1000);
                 $result = bmhBodyRules($body, $structure, $this->debug_body_rule);
                 break;
             default:
                 // unsupport Content-type
                 $this->output('Msg #' . $pos . ' is unsupported Content-Type:' . $structure->type, VERBOSE_REPORT);
                 return false;
         }
     } else {
         // internal error
         $this->error_msg = 'Internal Error: unknown type';
         return false;
     }
     $email = $result['email'];
     $bounce_type = $result['bounce_type'];
     if ($this->moveHard && $result['remove'] == 1) {
         $remove = 'moved (hard)';
     } elseif ($this->moveSoft && $result['remove'] == 1) {
  

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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