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


PHP imap_8bit函数代码示例

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


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

function mime_header_many($array)
{
    $return = "";
    if (!empty($array[0][0])) {
        for ($j = 0; $j <= count($array) - 1; $j++) {
            $return2 = "";
            for ($i = 0; $i <= count($array[$j]) - 1; $i++) {
                if ($i == count($array[$j]) - 1) {
                    if (count($array[$j]) == 1) {
                        $return2 .= "<" . $array[$j][$i] . ">";
                    } else {
                        $return2 = str_replace(" ", "_", "=?UTF-8?Q?" . imap_8bit($return2) . "?=") . " <" . $array[$j][$i] . ">";
                    }
                    if ($j < count($array) - 1) {
                        $return2 .= ", ";
                    }
                } else {
                    $return2 .= $array[$j][$i] . " ";
                }
            }
            $return .= $return2;
        }
    }
    return $return;
}
开发者ID:TeeAaTeeUu,项目名称:risteily_ilmo2,代码行数:25,代码来源:mailer.php

示例3: email

function email($e_mail, $subject, $message, $headers)
 {
  // add headers for utf-8 message
  $headers .= "\r\n";
  $headers .= 'From: ijgc-online.com <ijgc@ijgc-online.com>' . "\r\n";
  $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-type: text/plain; charset=utf-8\r\n";
  $headers .= "Content-Transfer-Encoding: quoted-printable\r\n";

  // encode subject
  //=?UTF-8?Q?encoded_text?=

  // work a round: for subject with wordwrap
  // not fixed, no possibility to have one in a single char
  $subject = wordwrap($subject, 25, "\n", FALSE);
  $subject = explode("\n", $subject);
  array_walk($subject, imap8bit);
  $subject = implode("\r\n ", $subject);
  $subject = "=?UTF-8?Q?".$subject."?=";

  // encode e-mail message
  $message = imap_8bit($message);

  return(mail("$e_mail", "$subject", "$message", "$headers"));
 }
开发者ID:bryanbacus,项目名称:skripsi-martin,代码行数:25,代码来源:sendmail.php

示例4: encodeHeader

 function encodeHeader($_string, $_encoding = 'q')
 {
     switch ($_encoding) {
         case "q":
             if (!preg_match("/[€-ÿ]/", $_string)) {
                 // nothing to quote, only 7 bit ascii
                 return $_string;
             }
             $string = imap_8bit($_string);
             $stringParts = explode("=\r\n", $string);
             while (list($key, $value) = each($stringParts)) {
                 if (!empty($retString)) {
                     $retString .= " ";
                 }
                 $value = str_replace(" ", "_", $value);
                 // imap_8bit does not convert "?"
                 // it does not need, but it should
                 $value = str_replace("?", "=3F", $value);
                 $retString .= "=?" . strtoupper($this->displayCharset) . "?Q?" . $value . "?=";
             }
             #exit;
             return $retString;
             break;
         default:
             return $_string;
     }
 }
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:27,代码来源:class.bo.inc.php

示例5: headerQuotedPrintableEncode

 function headerQuotedPrintableEncode($string, $encoding = 'UTF-8')
 {
     $string = str_replace(" ", "_", trim($string));
     // We need to delete "=\r\n" produced by imap_8bit() and replace '?'
     $string = str_replace("?", "=3F", str_replace("=\r\n", "", imap_8bit($string)));
     // Now we split by \r\n - i'm not sure about how many chars (header name counts or not?)
     $string = chunk_split($string, 73);
     // We also have to remove last unneeded \r\n :
     $string = substr($string, 0, strlen($string) - 2);
     // replace newlines with encoding text "=?UTF ..."
     $string = str_replace("\r\n", "?=" . HEAD_CRLF . " =?" . $encoding . "?Q?", $string);
     return '=?' . $encoding . '?Q?' . $string . '?=';
 }
开发者ID:PiratenparteiHessen,项目名称:wikiarguments,代码行数:13,代码来源:mail.php

示例6: email_encode

function email_encode($String = '', $Caracteres = 'ISO-8859-1')
{
    // Quoted-printed (Q)
    if (function_exists('quoted_printable_encode')) {
        $String = quoted_printable_encode($String);
        $RT = '=?' . $Caracteres . '?Q?' . $String . '?=';
    } else {
        // IMAP 8bit (Q)
        if (function_exists('imap_8bit')) {
            $String = imap_8bit($String);
            $RT = '=?' . $Caracteres . '?Q?' . $String . '?=';
        } else {
            $String = base64_encode($String);
            $RT = '=?' . $Caracteres . '?B?' . $String . '?=';
        }
    }
    return $RT;
}
开发者ID:juniorug,项目名称:vidacon,代码行数:18,代码来源:Contato.php

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

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

示例9: read

 private function read()
 {
     $allMails = imap_search($this->conn, 'ALL');
     if ($allMails) {
         rsort($allMails);
         foreach ($allMails as $email_number) {
             $overview = imap_fetch_overview($this->conn, $email_number, 0);
             $structure = imap_fetchstructure($this->conn, $email_number);
             $body = '';
             if (isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) {
                 $part = $structure->parts[1];
                 $body = imap_fetchbody($this->conn, $email_number, 2);
                 if ($part->encoding == 3) {
                     $body = imap_base64($body);
                 } else {
                     if ($part->encoding == 1) {
                         $body = imap_8bit($body);
                     } else {
                         $body = imap_qprint($body);
                     }
                 }
             }
             $body = utf8_decode($body);
             $fromaddress = utf8_decode(imap_utf7_encode($overview[0]->from));
             $subject = mb_decode_mimeheader($overview[0]->subject);
             $date = utf8_decode(imap_utf8($overview[0]->date));
             $date = date('Y-m-d H:i:s', strtotime($date));
             $key = md5($fromaddress . $subject . $body);
             //save to MySQL
             $sql = "SELECT count(*) FROM EMAIL_INFORMATION WHERE IDMAIL = " . $this->id . " AND CHECKVERS = \"" . $key . "\"";
             $resul = $this->pdo->query($sql)->fetch();
             if ($resul[0] == 0) {
                 $this->pdo->prepare("INSERT INTO EMAIL_INFORMATION (IDMAIL,FROMADDRESS,SUBJECT,DATE,BODY,CHECKVERS) VALUES (?,?,?,?,?,?)");
                 $this->pdo->execute(array($this->id, $fromaddress, $subject, $date, $body, $key));
             }
         }
     }
 }
开发者ID:GPierre-Antoine,项目名称:projetphp,代码行数:38,代码来源:Email.php

示例10: build_message

 function build_message($part)
 {
     $message = $part['message'];
     $encoding = $part['encoding'];
     $charset = $part['charset'];
     switch ($encoding) {
         case 'base64':
             $message = chunk_split(base64_encode($message));
             break;
         case 'quoted-printable':
             $message = imap_8bit($message);
             break;
         default:
             break;
     }
     $val = 'Content-Type: ' . $part['ctype'] . ';';
     $val .= $part['charset'] ? ' charset=' . $part['charset'] : '';
     $val .= $part['name'] ? $this->crlf . "\tname=\"" . $part['name'] . '"' : '';
     $val .= $this->crlf . 'Content-Transfer-Encoding: ' . $encoding;
     $val .= $part['name'] ? $this->crlf . 'Content-Disposition: attachment;' . $this->crlf . "\tfilename=\"" . $part['name'] . "\"" : '';
     $val .= $this->crlf . $this->crlf . $message . $this->crlf;
     return $val;
 }
开发者ID:patmark,项目名称:care2x-tz,代码行数:23,代码来源:class_send.php

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

示例12: decodeString

 private function decodeString($string, $encoding)
 {
     switch ($encoding) {
         case self::ENC_7BIT:
             return $string;
         case self::ENC_8BIT:
             return quoted_printable_decode(imap_8bit($string));
         case self::ENC_BINARY:
             return imap_binary($string);
         case self::ENC_BASE64:
             return imap_base64($string);
         case self::ENC_QUOTED_PRINTABLE:
             return quoted_printable_decode($string);
         case self::ENC_OTHER:
             return $string;
         default:
             return $string;
     }
 }
开发者ID:zalazdi,项目名称:laravel-imap,代码行数:19,代码来源:Message.php

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

示例14: _wordEncode

 /**
  * Encode a string making it an encoded word as RFC2047 wants
  * @author "Emiliano 'AlberT' Gabrielli" <emiliano.gabrielli@dearchitettura.com>
  * @access private
  * 
  * @param string $str: the string to be encoded
  * @param int $offset: an optional offset to be counted for the first line
  * @return string the encoded string, made of N encoded words as the original lenght impose
  */
 function _wordEncode($str, $offset = 0)
 {
     if (!$this->canEncode) {
         return $addr;
     }
     $cs = $this->charset;
     $str = str_replace(array(' ', "=\r\n", '?'), array('_', '', '=3F'), trim(imap_8bit($str)));
     $enlen = strlen("=?{$cs}?Q??=");
     // -4 is to ensure we do not truncate a trailing encoded char
     $max_fst_line_len = 75 - $enlen - $offset - 2;
     if ($this->_strlen($str) <= $max_fst_line_len) {
         return "=?{$cs}?Q?{$str}?=";
     }
     if (FALSE !== $this->_strpos($str, '=', $max_fst_line_len - 3)) {
         $max_fst_line_len -= 3;
     }
     $fst_line = $this->_substr($str, 0, $max_fst_line_len);
     $str = $this->_substr($str, $max_fst_line_len);
     $str = chunk_split($str, 75 - $enlen, "\r\n");
     // remove last unneeded CRLF
     $str = $this->_substr($str, 0, -2);
     $arows = explode("\r\n", $str);
     //reattach the first line
     array_unshift($arows, $fst_line);
     return '=?' . $cs . '?Q?' . implode("?=\r\n =?{$cs}?Q?", $arows) . '?=';
 }
开发者ID:magsilva,项目名称:dotproject,代码行数:35,代码来源:libmail.class.php

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


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