本文整理汇总了PHP中imap_8bit函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_8bit函数的具体用法?PHP imap_8bit怎么用?PHP imap_8bit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_8bit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 <[email protected]>' . "\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" <[email protected]>
* @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
示例16: generate_cool_url
if (in_array('pdf', $reportFormat)) {
$report_html = $generate->generateReport(90, "HTML", false);
ITS4YouReports::sshow($report_html);
exit;
$generate_pdf_filename = $tmpDir . generate_cool_url($generate->pdf_filename);
$fileName = $rootDirectory . $tempFileName . $generate->pdf_filename . '.xls';
if ($generate_pdf_filename != "" && file_exists($generate_pdf_filename)) {
$fileName_arr = explode(".", $generate->pdf_filename);
$fileName_arr[0] .= '_' . preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $currentTime);
$fileName = implode(".", $fileName_arr);
$attachments[$fileName] = $generate_pdf_filename;
}
}
if (in_array('xls', $reportFormat)) {
$report_data = $generate->generateReport(90, "XLS", false);
$ITS4YouReports_xls = "Reports4You_1_90.xls";
$fileName_arr = explode(".", $ITS4YouReports_xls);
$fileName_arr[0] .= '_' . preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $currentTime);
$fileName = implode(".", $fileName_arr);
$fileName_path = $tmpDir . $ITS4YouReports_xls;
$generate->writeReportToExcelFile($fileName_path, $report_data);
$attachments[$fileName] = $fileName_path;
}
foreach ($attachments as $attachmentName => $path) {
$vtigerMailer->AddAttachment($path, "=?ISO-8859-15?Q?" . imap_8bit(html_entity_decode($attachmentName, ENT_QUOTES, "UTF-8")) . "?=");
}
$send_result = $vtigerMailer->Send(true);
echo "SEND RESULT -> " . $send_result . "<br />";
foreach ($attachments as $attachmentName => $path) {
unlink($path);
}
开发者ID:cin-system,项目名称:cinrepo,代码行数:31,代码来源:Test.php
示例17: decode
/**
* Decode given string with encoding in current string and convert it to UTF-8 from part charset
*
* @param $string
* @return string
*/
private function decode($string)
{
if (!$string) {
return $string;
}
//transfer encoding
switch (strtolower($this->contentTransferEncoding)) {
case "7bit":
$decodedString = mb_convert_encoding($string, "UTF-8", "auto");
break;
case "8bit":
$decodedString = imap_8bit($string);
break;
case "binary":
$decodedString = imap_base64(imap_binary($string));
break;
case "base64":
$decodedString = imap_base64($string);
break;
case "quoted-printable":
$decodedString = imap_qprint($string);
break;
default:
throw new \UnexpectedValueException('Cannot decode ' . $this->contentTransferEncoding);
}
//do not convert if string is attachment content
if ($this->disposition == "attachment") {
return $decodedString;
}
//charset encoding
//TODO add different charsets
$decodedString = quoted_printable_decode($decodedString);
if (in_array($this->charset, ['windows-1250', 'koi8-r'])) {
return iconv(strtoupper($this->charset), "UTF-8", $decodedString);
} else {
return mb_convert_encoding($decodedString, "UTF-8", strtoupper($this->charset));
}
}
开发者ID:artemevsin,项目名称:imap,代码行数:44,代码来源:EmbeddedPart.php
示例18: vexim_encode_header
/**
* Properly encode a mail header text for using with mail().
*
* @param string $text the text to encode
* @return string The encoded header
*/
function vexim_encode_header($text)
{
if (function_exists('mb_encode_mimeheader')) {
mb_internal_encoding('UTF-8');
$text = mb_encode_mimeheader($text, 'UTF-8', 'Q');
} elseif (function_exists('imap_8bit')) {
$text = str_replace(" ", "_", imap_8bit(trim($text)));
$text = str_replace("?", "=3F", $text);
$text = str_replace("=\r\n", "?=\r\n =?UTF-8?Q?", $text);
$text = "=?UTF-8?Q?" . $text . "?=";
}
// if both mb and imap are not available, simply return what was given.
// this isn't standards-compliant, and the header will be displayed
// incorrectly if it contains accented letters. Let's just hope it won't
// be the case too often. :)
return $text;
}
开发者ID:rimas-kudelis,项目名称:vexim2,代码行数:23,代码来源:functions.php
示例19: 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
示例20: qp_encode
function qp_encode($text)
{
if (function_exists('quoted_printable_encode')) {
return quoted_printable_encode($text);
} elseif (function_exists('imap_8bit')) {
return imap_8bit($text);
} else {
$arrEncodeSupport = mb_list_encodings();
if (array_search('Quoted-Printable', $arrEncodeSupport) != FALSE) {
return mb_convert_encoding($text, 'Quoted-Printable', "JIS");
} else {
$crlf = "\r\n";
$text = trim($text);
$lines = preg_split("/(\r\n|\n|\r)/s", $text);
$out = '';
$temp = '';
foreach ($lines as $line) {
for ($j = 0; $j < strlen($line); $j++) {
$char = substr($line, $j, 1);
$ascii = ord($char);
if ($ascii < 32 || $ascii == 61 || $ascii > 126) {
$char = '=' . strtoupper(dechex($ascii));
}
if (strlen($temp) + strlen($char) >= 76) {
$out .= $temp . '=' . $crlf;
$temp = '';
}
$temp .= $char;
}
}
$out .= $temp;
return trim($out);
}
}
}
开发者ID:naonaox1126,项目名称:vizualizer,代码行数:35,代码来源:Sendmail.php
注:本文中的imap_8bit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论