当前位置: 首页>>代码示例>>PHP>>正文


PHP imap_binary函数代码示例

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


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

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

示例2: getdecodevalue

function getdecodevalue($message,$coding) {
		switch($coding) {
			case 0:
			case 1:
				$message = imap_8bit($message);
				break;
			case 2:
				$message = imap_binary($message);
				break;
			case 3:
			case 5:
				$message=imap_base64($message);
				break;
			case 4:
				$message = imap_qprint($message);
				break;
		}
		return $message;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:19,代码来源:checkmail_functions.php

示例3: decode

 function decode($encoding, $text)
 {
     switch ($encoding) {
         case 1:
             $text = imap_8bit($text);
             break;
         case 2:
             $text = imap_binary($text);
             break;
         case 3:
             $text = imap_base64($text);
             break;
         case 4:
             $text = imap_qprint($text);
             break;
         case 5:
         default:
             $text = $text;
     }
     return $text;
 }
开发者ID:iHunt101,项目名称:OsTicket,代码行数:21,代码来源:class.mailfetch.php

示例4: getAttach

 /**
  * get attach of the message
  *
  * @param string $msgCount
  * @param string $path
  * @return array
  */
 public function getAttach($msgCount, $path)
 {
     $struckture = imap_fetchstructure($this->_connect, $msgCount, FT_UID);
     print_r($struckture->parts);
     $attach = array();
     if ($struckture->parts) {
         foreach ($struckture->parts as $key => $value) {
             $encoding = $struckture->parts[$key]->encoding;
             if ($struckture->parts[$key]->ifdparameters) {
                 $name = $this->subjectDecode($struckture->parts[$key]->dparameters[0]->value);
                 $message = imap_fetchbody($this->_connect, $msgCount, $key + 1, FT_UID);
                 if ($encoding == 0) {
                     $message = imap_8bit($message);
                 } else {
                     if ($encoding == 1) {
                         $message = imap_8bit($message);
                     } else {
                         if ($encoding == 2) {
                             $message = imap_binary($message);
                         } else {
                             if ($encoding == 3) {
                                 $message = imap_base64($message);
                             } else {
                                 if ($encoding == 4) {
                                     $message = quoted_printable_decode($message);
                                 }
                             }
                         }
                     }
                 }
                 try {
                     $name = $this->subjectDecode($name);
                     $this->downAttach($path, $name, $message);
                     echo $name . "1\n";
                     $attach[] = $name;
                 } catch (Exception $e) {
                     echo '附件下载失败\\n';
                 }
             }
             if ($struckture->parts[$key]->parts) {
                 foreach ($struckture->parts[$key]->parts as $keyb => $valueb) {
                     $encoding = $struckture->parts[$key]->parts[$keyb]->encoding;
                     if ($struckture->parts[$key]->parts[$keyb]->ifdparameters) {
                         $name = $struckture->parts[$key]->parts[$keyb]->dparameters[0]->value;
                         $partnro = $key + 1 . "." . ($keyb + 1);
                         $message = imap_fetchbody($this->_connect, $msgCount, $partnro, FT_UID);
                         if ($encoding == 0) {
                             $message = imap_8bit($message);
                         } else {
                             if ($encoding == 1) {
                                 $message = imap_8bit($message);
                             } else {
                                 if ($encoding == 2) {
                                     $message = imap_binary($message);
                                 } else {
                                     if ($encoding == 3) {
                                         $message = imap_base64($message);
                                     } else {
                                         if ($encoding == 4) {
                                             $message = quoted_printable_decode($message);
                                         }
                                     }
                                 }
                             }
                         }
                         try {
                             $name = $this->subjectDecode($name);
                             $this->downAttach($path, $name, $message);
                             echo $name . "2\n";
                             $attach[] = $name;
                         } catch (Exception $e) {
                             echo "下载附件失败\n";
                         }
                     }
                 }
             }
         }
     }
     return $attach;
 }
开发者ID:ohjack,项目名称:newErp,代码行数:87,代码来源:Get_Email.class.php

示例5: getParts

 /**
  * Splits out body parts
  * ie. plain, HTML, attachment
  *
  * @param string $content The content to parse
  * @param array  $parts   The existing parts
  *
  * @return array
  */
 private function getParts($content, array $parts = array())
 {
     //separate the head and the body
     list($head, $body) = preg_split("/\n\\s*\n/", $content, 2);
     //front()->output($head);
     //get the headers
     $head = $this->getHeaders($head);
     //if content type is not set
     if (!isset($head['content-type'])) {
         return $parts;
     }
     //split the content type
     if (is_array($head['content-type'])) {
         $type = array($head['content-type'][1]);
         if (strpos($type[0], ';') !== false) {
             $type = explode(';', $type[0], 2);
         }
     } else {
         $type = explode(';', $head['content-type'], 2);
     }
     //see if there are any extra stuff
     $extra = array();
     if (count($type) == 2) {
         $extra = explode('; ', str_replace(array('"', "'"), '', trim($type[1])));
     }
     //the content type is the first part of this
     $type = trim($type[0]);
     //foreach extra
     foreach ($extra as $i => $attr) {
         //transform the extra array to a key value pair
         $attr = explode('=', $attr, 2);
         if (count($attr) > 1) {
             list($key, $value) = $attr;
             $extra[$key] = $value;
         }
         unset($extra[$i]);
     }
     //if a boundary is set
     if (isset($extra['boundary'])) {
         //split the body into sections
         $sections = explode('--' . str_replace(array('"', "'"), '', $extra['boundary']), $body);
         //we only want what's in the middle of these sections
         array_pop($sections);
         array_shift($sections);
         //foreach section
         foreach ($sections as $section) {
             //get the parts of that
             $parts = $this->getParts($section, $parts);
         }
     } else {
         //if name is set, it's an attachment
         //if encoding is set
         if (isset($head['content-transfer-encoding'])) {
             //the goal here is to make everytihg utf-8 standard
             if (is_array($head['content-transfer-encoding'])) {
                 $head['content-transfer-encoding'] = array_pop($head['content-transfer-encoding']);
             }
             switch (strtolower($head['content-transfer-encoding'])) {
                 case 'binary':
                     $body = imap_binary($body);
                     break;
                 case 'base64':
                     $body = base64_decode($body);
                     break;
                 case 'quoted-printable':
                     $body = quoted_printable_decode($body);
                     break;
                 case '7bit':
                     $body = mb_convert_encoding($body, 'UTF-8', 'ISO-2022-JP');
                     break;
                 default:
                     break;
             }
         }
         if (isset($extra['name'])) {
             //add to parts
             $parts['attachment'][$extra['name']][$type] = $body;
         } else {
             //it's just a regular body
             //add to parts
             $parts[$type] = $body;
         }
     }
     return $parts;
 }
开发者ID:kamaroly,项目名称:Mail,代码行数:94,代码来源:Imap.php

示例6: DecodificaMensagem

 public function DecodificaMensagem($Mensagem, $Codificacao)
 {
     switch ($Codificacao) {
         case 0:
         case 1:
             $Mensagem = imap_8bit($Mensagem);
             break;
         case 2:
             $Mensagem = imap_binary($Mensagem);
             break;
         case 3:
         case 5:
         case 6:
         case 7:
             $Mensagem = imap_base64($Mensagem);
             break;
         case 4:
             $Mensagem = imap_qprint($Mensagem);
             break;
     }
     return $Mensagem;
 }
开发者ID:tricardo,项目名称:CartorioPostal_old,代码行数:22,代码来源:ChamadoDAO.php

示例7: getEmailAttachments

function getEmailAttachments($inbox, $email_number, $structure)
{
    $attachments = array();
    // Tomar adjuntos de e-mail
    if (isset($structure->parts) && count($structure->parts)) {
        for ($i = 0; $i < count($structure->parts); $i++) {
            $is_attachment = false;
            $filename = "";
            $name = "";
            $attachment = "";
            if ($structure->parts[$i]->ifdparameters) {
                foreach ($structure->parts[$i]->dparameters as $object) {
                    if (strtolower($object->attribute) == 'name') {
                        $is_attachment = true;
                        $filename = $object->value;
                    }
                }
            }
            if ($structure->parts[$i]->ifparameters) {
                foreach ($structure->parts[$i]->parameters as $object) {
                    if (strtolower($object->attribute) == 'name') {
                        $is_attachment = true;
                        $filename = $object->value;
                    }
                }
            }
            if ($is_attachment) {
                $attachment = imap_fetchbody($inbox, $email_number, $i + 1);
                switch ($structure->parts[$i]->encoding) {
                    case 0:
                    case 1:
                        $attachment = imap_8bit($attachment);
                        break;
                    case 2:
                        $attachment = imap_binary($attachment);
                        break;
                    case 3:
                    case 5:
                        $attachment = imap_base64($attachment);
                        break;
                    case 4:
                        $attachment = imap_qprint($attachment);
                        break;
                }
                $attachments[$i] = array('is_attachment' => $is_attachment, 'filename' => $filename, 'name' => $name, 'attachment' => $attachment);
            }
        }
    }
    // Procesar adjuntos y formatear arreglo
    $tmpAttachments = array();
    foreach ($attachments as $attachment) {
        mb_internal_encoding('UTF-8');
        $attachment["filename"] = str_replace("_", " ", mb_decode_mimeheader($attachment["filename"]));
        $attachmentArray = array();
        $tmpFilenameArray = explode(".", $attachment["filename"]);
        $basename = $tmpFilenameArray[0];
        $extension = end($tmpFilenameArray);
        $attachmentArray["basename"] = $basename;
        switch (strtolower($extension)) {
            case 'xml':
                $attachmentArray["extension"] = "xml";
                $attachmentArray["attachment"] = $attachment["attachment"];
                $tmpAttachments[] = $attachmentArray;
                break;
            case 'zip':
                $zipArray = processZipFile($attachment["attachment"]);
                foreach ($zipArray as $zippedFile) {
                    $attachmentArray = array();
                    $attachmentArray["basename"] = $zippedFile["basename"];
                    $attachmentArray["extension"] = $zippedFile["extension"];
                    $attachmentArray["attachment"] = $zippedFile["attachment"];
                    $tmpAttachments[] = $attachmentArray;
                }
                break;
            default:
                $attachmentArray["extension"] = $extension;
                $attachmentArray["attachment"] = $attachment["attachment"];
                $tmpAttachments[] = $attachmentArray;
                break;
        }
    }
    // Armar arreglo final (juntar xml con su pdf respectivo)
    $returnArray = array();
    foreach ($tmpAttachments as $attachment) {
        $tmpArray = array();
        if (strtolower($attachment["extension"]) == "xml") {
            $tmpArray = array("xml_basename" => $attachment["basename"], "xml_extension" => $attachment["extension"], "xml_attachment" => $attachment["attachment"], "pdf_basename" => "", "pdf_extension" => "", "pdf_attachment" => "");
            foreach ($tmpAttachments as $pdfAttachment) {
                if ((strtolower($pdfAttachment["extension"]) == "pdf" || strtolower($pdfAttachment["extension"]) == "tiff") && $pdfAttachment["basename"] == $attachment["basename"]) {
                    $tmpArray["pdf_basename"] = $pdfAttachment["basename"];
                    $tmpArray["pdf_extension"] = $pdfAttachment["extension"];
                    $tmpArray["pdf_attachment"] = $pdfAttachment["attachment"];
                }
            }
            $returnArray[] = $tmpArray;
        }
    }
    return $returnArray;
}
开发者ID:elcuy,项目名称:Novopan,代码行数:99,代码来源:JobDocElecMailChecker.php

示例8: getRecursiveAttached

 /**
  * Private function : Recursivly get attached documents
  *
  * @param $mid          message id
  * @param $path         temporary path
  * @param $maxsize      of document to be retrieved
  * @param $structure    of the message or part
  * @param $part         part for recursive
  *
  * Result is stored in $this->files
  **/
 function getRecursiveAttached($mid, $path, $maxsize, $structure, $part = "")
 {
     if ($structure->type == 1) {
         // multipart
         reset($structure->parts);
         while (list($index, $sub) = each($structure->parts)) {
             $this->getRecursiveAttached($mid, $path, $maxsize, $sub, $part ? $part . "." . ($index + 1) : $index + 1);
         }
     } else {
         $filename = '';
         if ($structure->ifdparameters) {
             // get filename of attachment if present
             // if there are any dparameters present in this part
             if (count($structure->dparameters) > 0) {
                 foreach ($structure->dparameters as $dparam) {
                     if (Toolbox::strtoupper($dparam->attribute) == 'NAME' || Toolbox::strtoupper($dparam->attribute) == 'FILENAME') {
                         $filename = $dparam->value;
                     }
                 }
             }
         }
         //if no filename found
         if (empty($filename) && $structure->ifparameters) {
             // if there are any parameters present in this part
             if (count($structure->parameters) > 0) {
                 foreach ($structure->parameters as $param) {
                     if (Toolbox::strtoupper($param->attribute) == 'NAME' || Toolbox::strtoupper($param->attribute) == 'FILENAME') {
                         $filename = $param->value;
                     }
                 }
             }
         }
         if (empty($filename) && $structure->type == 5 && $structure->subtype) {
             // Embeded image come without filename - generate trivial one
             $filename = "image_{$part}." . $structure->subtype;
         }
         // if no filename found, ignore this part
         if (empty($filename)) {
             return false;
         }
         //try to avoid conflict between inline image and attachment
         $i = 2;
         while (in_array($filename, $this->files)) {
             //replace filename with name_(num).EXT by name_(num+1).EXT
             $new_filename = preg_replace("/(.*)_([0-9])*(\\.[a-zA-Z0-9]*)\$/", "\$1_" . $i . "\$3", $filename);
             if ($new_filename !== $filename) {
                 $filename = $new_filename;
             } else {
                 //the previous regex didn't found _num pattern, so add it with this one
                 $filename = preg_replace("/(.*)(\\.[a-zA-Z0-9]*)\$/", "\$1_" . $i . "\$2", $filename);
             }
             $i++;
         }
         $filename = $this->decodeMimeString($filename);
         if ($structure->bytes > $maxsize) {
             $this->addtobody .= "\n\n" . sprintf(__('%1$s: %2$s'), __('Too large attached file'), sprintf(__('%1$s (%2$s)'), $filename, Toolbox::getSize($structure->bytes)));
             return false;
         }
         if (!Document::isValidDoc($filename)) {
             //TRANS: %1$s is the filename and %2$s its mime type
             $this->addtobody .= "\n\n" . sprintf(__('%1$s: %2$s'), __('Invalid attached file'), sprintf(__('%1$s (%2$s)'), $filename, $this->get_mime_type($structure)));
             return false;
         }
         if ($message = imap_fetchbody($this->marubox, $mid, $part)) {
             switch ($structure->encoding) {
                 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;
             }
             if (file_put_contents($path . $filename, $message)) {
                 $this->files[$filename] = $filename;
                 // If embeded image, we add a tag
                 if ($structure->type == 5 && $structure->subtype) {
                     end($this->files);
                     $tag = Rule::getUuid();
                     $this->tags[$filename] = $tag;
                     // Link file based on id
                     if (isset($structure->id)) {
                         $clean = array('<' => '', '>' => '');
                         $this->altfiles[strtr($structure->id, $clean)] = $filename;
//.........这里部分代码省略.........
开发者ID:remicollet,项目名称:glpi,代码行数:101,代码来源:mailcollector.class.php

示例9: decode

 function decode($text, $encoding)
 {
     switch ($encoding) {
         case 1:
             $text = imap_8bit($text);
             break;
         case 2:
             $text = imap_binary($text);
             break;
         case 3:
             // imap_base64 implies strict mode. If it refuses to decode the
             // data, then fallback to base64_decode in non-strict mode
             $text = ($conv = imap_base64($text)) ? $conv : base64_decode($text);
             break;
         case 4:
             $text = imap_qprint($text);
             break;
     }
     return $text;
 }
开发者ID:KM-MFG,项目名称:osTicket-1.8,代码行数:20,代码来源:class.mailfetch.php

示例10: get_attach

 /**
  * get attach of the message
  *
  * @param string $msg_count
  * @param string $path
  * @return array
  */
 public function get_attach($msg_count, $path)
 {
     if (!$this->_connect) {
         return false;
     }
     $struckture = imap_fetchstructure($this->_connect, $msg_count);
     $ar = "";
     if ($struckture->parts) {
         foreach ($struckture->parts as $key => $value) {
             $enc = $struckture->parts[$key]->encoding;
             $subtype = $struckture->parts[$key]->subtype;
             $text_type = array("PLAIN", "HTML", "ALTERNATIVE");
             if (in_array($subtype, $text_type)) {
                 continue;
             }
             if ($struckture->parts[$key]->ifdparameters) {
                 $name = $this->mail_decode($struckture->parts[$key]->dparameters[0]->value);
                 $cid = $struckture->parts[$key]->id;
                 $cid = substr($cid, 1, strlen($cid) - 2);
                 $disposition = $struckture->parts[$key]->disposition;
                 if (empty($disposition)) {
                     $disposition = "INLINE";
                 }
                 $name = $cid . "_" . $disposition . "_" . $name;
                 $message = imap_fetchbody($this->_connect, $msg_count, $key + 1);
                 if ($enc == 0) {
                     $message = imap_8bit($message);
                 }
                 if ($enc == 1) {
                     $message = imap_8bit($message);
                 }
                 if ($enc == 2) {
                     $message = imap_binary($message);
                 }
                 if ($enc == 3) {
                     $message = imap_base64($message);
                 }
                 if ($enc == 4) {
                     $message = quoted_printable_decode($message);
                 }
                 if ($enc == 5) {
                     $message = $message;
                 }
                 $fp = fopen($path . urlencode($name), "w");
                 fwrite($fp, $message);
                 fclose($fp);
                 $ar = $ar . $name . ",";
             }
             if ($struckture->parts[$key]->ifparameters && $struckture->parts[$key]->ifdparameters == 0) {
                 if ($struckture->parts[$key]->parameters[0]->attribute == "NAME") {
                     $name = $this->mail_decode($struckture->parts[$key]->parameters[0]->value);
                 }
                 if ($struckture->parts[$key]->parameters[1]->attribute == "NAME") {
                     $name = $this->mail_decode($struckture->parts[$key]->parameters[1]->value);
                 }
                 $cid = $struckture->parts[$key]->id;
                 $cid = substr($cid, 1, strlen($cid) - 2);
                 $disposition = $struckture->parts[$key]->disposition;
                 if (empty($disposition)) {
                     $disposition = "INLINE";
                 }
                 $name = $cid . "_" . $disposition . "_" . $name;
                 $message = imap_fetchbody($this->_connect, $msg_count, $key + 1);
                 if ($enc == 0) {
                     $message = imap_8bit($message);
                 }
                 if ($enc == 1) {
                     $message = imap_8bit($message);
                 }
                 if ($enc == 2) {
                     $message = imap_binary($message);
                 }
                 if ($enc == 3) {
                     $message = imap_base64($message);
                 }
                 if ($enc == 4) {
                     $message = quoted_printable_decode($message);
                 }
                 if ($enc == 5) {
                     $message = $message;
                 }
                 $fp = fopen($path . urlencode($name), "w");
                 fwrite($fp, $message);
                 fclose($fp);
                 $ar = $ar . $name . ",";
             }
             if ($struckture->parts[$key]->parts) {
                 foreach ($struckture->parts[$key]->parts as $keyb => $valueb) {
                     $enc = $struckture->parts[$key]->parts[$keyb]->encoding;
                     if ($struckture->parts[$key]->parts[$keyb]->ifdparameters) {
                         $name = $this->mail_decode($struckture->parts[$key]->parts[$keyb]->dparameters[0]->value);
                         $id = $struckture->parts[$key]->parts[$keyb]->id;
                         $disposition = $struckture->parts[$key]->parts[$keyb]->disposition;
//.........这里部分代码省略.........
开发者ID:zqstudio2015,项目名称:smeoa,代码行数:101,代码来源:receve.class.php

示例11: getAttachment

 /**
  * Get Attached File from Mail
  *
  * @param int $mid message id
  * @param string $path attachment storage path
  *
  * @param string $separator list separator for attachment names
  *
  * @return string
  */
 public function getAttachment($mid, $path, $separator = ',')
 {
     if (!$this->getMailBox()) {
         return false;
     }
     $structure = imap_fetchstructure($this->getMailBox(), $mid);
     $attachments = "";
     if (property_exists($structure, 'parts') && $structure->parts) {
         foreach (array_keys($structure->parts) as $key) {
             $enc = $structure->parts[$key]->encoding;
             if ($structure->parts[$key]->ifdparameters) {
                 $name = $structure->parts[$key]->dparameters[0]->value;
                 $message = imap_fetchbody($this->getMailBox(), $mid, $key + 1);
                 switch ($enc) {
                     case 0:
                         $message = imap_8bit($message);
                         break;
                     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;
                 }
                 $fp = fopen($path . $name, "w");
                 fwrite($fp, $message);
                 fclose($fp);
                 $attachments .= $name . $separator;
             }
             // Support for embedded attachments starts here
             if (property_exists($structure->parts[$key], 'parts')) {
                 foreach (array_keys($structure->parts[$key]->parts) as $keyB) {
                     $enc = $structure->parts[$key]->parts[$keyB]->encoding;
                     if ($structure->parts[$key]->parts[$keyB]->ifdparameters) {
                         $name = $structure->parts[$key]->parts[$keyB]->dparameters[0]->value;
                         $partNum = $key + 1 . "." . ($keyB + 1);
                         $message = imap_fetchbody($this->getMailBox(), $mid, $partNum);
                         switch ($enc) {
                             case 0:
                                 $message = imap_8bit($message);
                                 break;
                             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;
                         }
                         $fp = fopen($path . $name, "w");
                         fwrite($fp, $message);
                         fclose($fp);
                         $attachments .= $name . $separator;
                     }
                 }
             }
         }
     }
     /** Catch embedded images  */
     $embedded = $this->getEmbeddedImages(array('mid' => $mid, 'path' => $path, 'separator' => $separator));
     if ($embedded) {
         $attachments = $attachments . $embedded;
     }
     $attachments = substr($attachments, 0, strlen($attachments) - strlen($separator));
     return $attachments;
 }
开发者ID:paulbunyannet,项目名称:mail,代码行数:87,代码来源:GetMail.php

示例12: GetAttach

 function GetAttach($mid, $path)
 {
     if (!$this->marubox) {
         return false;
     }
     $struckture = imap_fetchstructure($this->marubox, $mid);
     $ar = "";
     if ($struckture->parts) {
         foreach ($struckture->parts as $key => $value) {
             $enc = $struckture->parts[$key]->encoding;
             if ($struckture->parts[$key]->ifdparameters) {
                 $name = $struckture->parts[$key]->dparameters[0]->value;
                 $message = imap_fetchbody($this->marubox, $mid, $key + 1);
                 switch ($enc) {
                     case 0:
                         $message = imap_8bit($message);
                         break;
                     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;
                     case 5:
                         $message = $message;
                         break;
                 }
                 $fp = fopen($path . $name, "w");
                 fwrite($fp, $message);
                 fclose($fp);
                 $ar = $ar . $name . ",";
             }
             // Support for embedded attachments starts here
             if ($struckture->parts[$key]->parts) {
                 foreach ($struckture->parts[$key]->parts as $keyb => $valueb) {
                     $enc = $struckture->parts[$key]->parts[$keyb]->encoding;
                     if ($struckture->parts[$key]->parts[$keyb]->ifdparameters) {
                         $name = $struckture->parts[$key]->parts[$keyb]->dparameters[0]->value;
                         $partnro = $key + 1 . "." . ($keyb + 1);
                         $message = imap_fetchbody($this->marubox, $mid, $partnro);
                         switch ($enc) {
                             case 0:
                                 $message = imap_8bit($message);
                                 break;
                             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;
                             case 5:
                                 $message = $message;
                                 break;
                         }
                         $fp = fopen($path . $name, "w");
                         fwrite($fp, $message);
                         fclose($fp);
                         $ar = $ar . $name . ",";
                     }
                 }
             }
         }
     }
     $ar = substr($ar, 0, strlen($ar) - 1);
     return $ar;
 }
开发者ID:tmlsoft,项目名称:main,代码行数:78,代码来源:receivemail.class.php

示例13: initMailPart

 /**
  * @param Message      $mail
  * @param              $partStructure
  * @param              $partNum
  * @param bool|true    $markAsSeen
  * @param bool|false   $isDsn
  */
 protected function initMailPart(Message $mail, $partStructure, $partNum, $markAsSeen = true, $isDsn = false)
 {
     $options = FT_UID;
     if (!$markAsSeen) {
         $options |= FT_PEEK;
     }
     $data = $partNum ? imap_fetchbody($this->getImapStream(), $mail->id, $partNum, $options) : imap_body($this->getImapStream(), $mail->id, $options);
     if ($partStructure->encoding == 1) {
         $data = imap_utf8($data);
     } elseif ($partStructure->encoding == 2) {
         $data = imap_binary($data);
     } elseif ($partStructure->encoding == 3) {
         $data = imap_base64($data);
     } elseif ($partStructure->encoding == 4) {
         $data = quoted_printable_decode($data);
     }
     $params = $this->getParameters($partStructure);
     // attachments
     $attachmentId = $partStructure->ifid ? trim($partStructure->id, " <>") : (isset($params['filename']) || isset($params['name']) ? mt_rand() . mt_rand() : null);
     if ($attachmentId) {
         if (empty($params['filename']) && empty($params['name'])) {
             $fileName = $attachmentId . '.' . strtolower($partStructure->subtype);
         } else {
             $fileName = !empty($params['filename']) ? $params['filename'] : $params['name'];
             $fileName = $this->decodeMimeStr($fileName, $this->serverEncoding);
             $fileName = $this->decodeRFC2231($fileName, $this->serverEncoding);
         }
         $attachment = new Attachment();
         $attachment->id = $attachmentId;
         $attachment->name = $fileName;
         if ($this->attachmentsDir) {
             $replace = ['/\\s/' => '_', '/[^0-9a-zа-яіїє_\\.]/iu' => '', '/_+/' => '_', '/(^_)|(_$)/' => ''];
             $fileSysName = preg_replace('~[\\\\/]~', '', $mail->id . '_' . $attachmentId . '_' . preg_replace(array_keys($replace), $replace, $fileName));
             $attachment->filePath = $this->attachmentsDir . DIRECTORY_SEPARATOR . $fileSysName;
             file_put_contents($attachment->filePath, $data);
         }
         $mail->addAttachment($attachment);
     } else {
         if (!empty($params['charset'])) {
             $data = $this->convertStringEncoding($data, $params['charset'], $this->serverEncoding);
         }
         if ($partStructure->type == 0 && $data) {
             if (strtolower($partStructure->subtype) == 'plain') {
                 $mail->textPlain .= $data;
             } else {
                 $mail->textHtml .= $data;
             }
         } elseif ($partStructure->type == 1 && $partStructure->ifsubtype && (strtolower($partStructure->subtype) == 'report' && isset($params['REPORT-TYPE']) && strtolower($params['REPORT-TYPE']) == 'delivery-status')) {
             $mail->dsnMessage = trim($data);
             $isDsn = true;
         } elseif ($partStructure->type == 2 && $data) {
             if ($isDsn || strtolower($partStructure->subtype) == 'delivery-status') {
                 $mail->dsnReport = $data;
             } else {
                 $mail->textPlain .= trim($data);
             }
         }
     }
     if (!empty($partStructure->parts)) {
         foreach ($partStructure->parts as $subPartNum => $subPartStructure) {
             if ($partStructure->type == 2 && $partStructure->subtype == 'RFC822') {
                 $this->initMailPart($mail, $subPartStructure, $partNum, $markAsSeen, $isDsn);
             } else {
                 $this->initMailPart($mail, $subPartStructure, $partNum . '.' . ($subPartNum + 1), $markAsSeen, $isDsn);
             }
         }
     }
 }
开发者ID:Yame-,项目名称:mautic,代码行数:75,代码来源:Mailbox.php

示例14: getAttachment

 /**
  * return content of messages attachment
  *
  * @return binary attachment
  * @param $id of the message
  * @param $index of the attachment (default: first attachment)
  */
 public function getAttachment($id, $index = 0)
 {
     // find message
     $attachments = false;
     $messageIndex = imap_msgno($this->imap, $id);
     $header = imap_headerinfo($this->imap, $messageIndex);
     $mailStruct = imap_fetchstructure($this->imap, $messageIndex);
     $attachments = $this->getAttachments($this->imap, $messageIndex, $mailStruct, "");
     if ($attachments == false) {
         return false;
     }
     // find attachment
     if ($index > count($attachments)) {
         return false;
     }
     $attachment = $attachments[$index];
     // get attachment body
     $partStruct = imap_bodystruct($this->imap, imap_msgno($this->imap, $id), $attachment['partNum']);
     $filename = $partStruct->dparameters[0]->value;
     $message = imap_fetchbody($this->imap, $id, $attachment['partNum'], FT_UID);
     switch ($attachment['enc']) {
         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 array("name" => $attachment['name'], "size" => $attachment['size'], "content" => $message);
 }
开发者ID:radub,项目名称:php-imap-client,代码行数:44,代码来源:Imap.php

示例15: decodeValue

 /**
  * Function to decode a part of the message
  * @param string $msgPart the message part to decode
  * @param string $encoding the encoding used
  * @return bool|string
  */
 protected function decodeValue($msgPart, $encoding)
 {
     switch ($encoding) {
         case ENC7BIT:
         case ENC8BIT:
             $msgPart = imap_8bit($msgPart);
             break;
         case ENCBINARY:
             $msgPart = imap_binary($msgPart);
             break;
         case ENCBASE64:
         case ENCOTHER:
             $msgPart = imap_base64($msgPart);
             break;
         case ENCQUOTEDPRINTABLE:
             $msgPart = imap_qprint($msgPart);
             break;
         default:
             return false;
     }
     return $msgPart;
 }
开发者ID:strong2much,项目名称:yii2-imap,代码行数:28,代码来源:Imap.php


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