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


PHP imap_mime_header_decode函数代码示例

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


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

示例1: pop_subject

function pop_subject()
{
    $username = 'inz_agi01';
    $password = 'ggwwds';
    $imap = imap_open("{pop3.163.com:995/pop3/ssl/novalidate-cert}", $username, $password);
    //    $imap = imap_open("{pop.21cn.com:110/pop/notls}", $username, $password);
    $message_count = imap_num_msg($imap);
    echo "------->>" . is_int($message_count);
    echo '$message_count' . $message_count . "\n";
    for ($i = $message_count; $i >= 1; $i--) {
        $header = imap_header($imap, $i);
        $date = $header->date;
        echo "************msg no: {$i} \n {$date} \n";
        $subjectArr = @imap_mime_header_decode($header->subject);
        if (is_array($subjectArr)) {
            $subject = '';
            foreach ($subjectArr as $subjectObj) {
                //遍历标题数组,获取所有标题text
                $subject .= trim($subjectObj->text);
            }
            $mailCharset = mb_detect_encoding($subject, array('UTF-8', 'GBK', 'LATIN1', 'BIG5'));
            echo $mailCharset . "\n";
            //查看邮件标题的编码
            $subject = mb_convert_encoding($subject, 'utf-8', $mailCharset);
            //对标题进行解码操作
            echo $subject . "\n";
        } else {
            continue;
        }
    }
    imap_close($imap);
}
开发者ID:sdgdsffdsfff,项目名称:qq_mail_login,代码行数:32,代码来源:pop_imap.php

示例2: actionIndex

 public function actionIndex()
 {
     $model = new Receive();
     error_reporting(E_ALL ^ E_WARNING);
     $obj = new receiveMail('tclrg', 'Luanruitest', 'tclrg@126.com', 'imap.126.com', 'imap', '993', 'ture');
     $obj->connect();
     $tot = $obj->getTotalMails();
     //查看邮箱是否有新邮件
     $old_email_count = Email::find()->count();
     for ($i = $tot; $i > $old_email_count; $i--) {
         $model = new Receive();
         $head = $obj->getHeaders($i);
         $head['subject'] = imap_mime_header_decode($head['subject'])[0]->text;
         $head['from'] = imap_mime_header_decode($head['from'])[0]->text;
         $head['fromName'] = imap_mime_header_decode($head['fromName'])[0]->text;
         $model->subject = $head['subject'];
         $model->sender = $head['from'];
         //            echo $i.$head['date']."</br>";
         //            echo $i.strtotime($head['date'])."</br>";
         //            echo $i.date("Y-m-d H:i:s",strtotime($head['date']))."</br>";
         $model->sendtime = date("Y-m-d H:i:s", strtotime($head['date']));
         $model->text = $obj->getBody($i);
         //            $model->sendtime=$head['date'];
         $model->save();
         //            echo $i.$head['date'];
     }
     $obj->close_mailbox();
 }
开发者ID:houzhenggang,项目名称:EmailManager,代码行数:28,代码来源:ReceiveController.php

示例3: decode

 protected function decode($value)
 {
     if (empty($value) || ($value = '')) {
         return '';
     }
     $decoded = '';
     $parts = imap_mime_header_decode($value);
     foreach ($parts as $part) {
         $charset = 'default' == $part->charset ? 'auto' : $part->charset;
         // imap_utf8 doesn't seem to work properly, so use Transcoder instead
         try {
             $decoded .= Transcoder::create()->transcode($part->text, $charset);
         } catch (\Ddeboer\Transcoder\Exception\UndetectableEncodingException $ex) {
             $decoded .= $part->text;
         } catch (\Ddeboer\Transcoder\Exception\UnsupportedEncodingException $ex) {
             $decoded .= $part->text;
         } catch (\Ddeboer\Transcoder\Exception\IllegalCharacterException $ex) {
             // force transcoding using iconv and ignore.
             $decoded .= @iconv($charset, 'UTF-8//IGNORE', $part->text);
         } catch (\Exception $ex) {
             // maybe any kind of exception.
             $decoded .= $part->text;
         }
     }
     return $decoded;
 }
开发者ID:shapecode,项目名称:imap,代码行数:26,代码来源:Parameters.php

示例4: getHeaders

 function getHeaders($mid)
 {
     if (!$this->marubox) {
         return false;
     }
     $mail_header = imap_header($this->marubox, $mid);
     $sender = $mail_header->from[0];
     //        var_dump(strtolower($sender->mailbox));
     //        return $this->marubox;
     $sender_replyto = $mail_header->reply_to[0];
     $mail_details = array();
     if (strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster') {
         date_default_timezone_set('PRC');
         $subject = imap_mime_header_decode($mail_header->subject);
         $toaddress = imap_mime_header_decode($mail_header->toaddress);
         $mail_details = array('from' => strtolower($sender->mailbox) . '@' . $sender->host, 'fromName' => "", 'fromName_charset' => "", 'toOth' => strtolower($sender_replyto->mailbox) . '@' . $sender_replyto->host, 'toNameOth' => "", 'subject' => $subject[0]->text, 'subject_charset' => $subject[0]->charset, 'mailDate' => date("Y-m-d H:i:s", $mail_header->udate), 'udate' => $mail_header->udate, 'to' => $toaddress[0]->text);
         if (isset($sender->personal)) {
             $sPersonal = imap_mime_header_decode($sender->personal);
             $mail_details['fromName'] = $sPersonal[0]->text;
             $mail_details['fromName_charset'] = $sPersonal[0]->charset;
         }
         if (isset($sender_replyto->personal)) {
             $rePersonal = imap_mime_header_decode($sender_replyto->personal);
             $mail_details['toNameOth'] = $rePersonal[0]->text;
         }
     }
     return $mail_details;
 }
开发者ID:TipTimesPHP,项目名称:tyj_oa,代码行数:28,代码来源:receivemail.class.php

示例5: decode

 protected function decode($value)
 {
     $decoded = '';
     $parts = imap_mime_header_decode($value);
     try {
         foreach ($parts as $part) {
             $charset = 'default' == $part->charset ? 'auto' : $part->charset;
             //Ajout COGIVEA fix encoding :
             $charset = $this->charset != '' && $charset == 'auto' ? $this->charset : $charset;
             //print $part->text."#".$this->charset."/".$charset."#"."\n";
             // imap_utf8 doesn't seem to work properly, so use Transcoder instead
             // Got from: https://github.com/Sawered/imap/commit/e739b7221c6e57521b38f7b56f78ba399acda888 and changed to UndetectableEncodingException
             try {
                 $decoded .= Transcoder::create()->transcode($part->text, $charset);
             } catch (IllegalCharacterException $e) {
                 //no warn, itis reality
                 //FIX COGIVEA
             } catch (UndetectableEncodingException $e) {
                 //no warn, it is reality, handle it somehow
                 $decoded = imap_utf8($part->text);
             }
         }
     } catch (Exception $e) {
     }
     return $decoded;
 }
开发者ID:gbcogivea,项目名称:imap,代码行数:26,代码来源:Parameters.php

示例6: decode

 public static function decode($string)
 {
     $parts = imap_mime_header_decode($string);
     $s = '';
     foreach ($parts as $part) {
         $s .= $part->text;
     }
     return $s;
 }
开发者ID:ephp,项目名称:imap,代码行数:9,代码来源:Mime.php

示例7: flat_mime_decode

 function flat_mime_decode($string)
 {
     $array = imap_mime_header_decode($string);
     $str = "";
     foreach ($array as $key => $part) {
         $str .= str_replace(['{', '}'], ['[', ']'], $part->text);
     }
     return $str;
 }
开发者ID:cjvaz,项目名称:expressomail,代码行数:9,代码来源:class.imap_attachment.inc.php

示例8: decode_imap_text

function decode_imap_text($str)
{
    $result = '';
    $decode_header = imap_mime_header_decode($str);
    foreach ($decode_header as $obj) {
        $result .= htmlspecialchars(rtrim($obj->text, "\t"));
    }
    return $result;
}
开发者ID:bhushansonar,项目名称:knewdog.com,代码行数:9,代码来源:list+-+Copy.php

示例9: decodeHeaderValue

 /**
  * Decodes a header value
  * @param string $value The value to decode
  * @return string Decoded value
  */
 public function decodeHeaderValue($value)
 {
     $result = '';
     $tokens = imap_mime_header_decode($value);
     foreach ($tokens as $token) {
         $result .= $token->text;
     }
     return $result;
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:14,代码来源:Parser.php

示例10: get_plain_text_subject

function get_plain_text_subject($mbox, $msgNum, $headers = null)
{
    $headers or $headers = imap_headerinfo($mbox, $msgNum);
    $subjectParts = imap_mime_header_decode($headers->Subject);
    $subject = '';
    foreach ($subjectParts as $p) {
        $subject .= $p->text;
    }
    return trim($subject);
}
开发者ID:rudiedirkx,项目名称:IMAP-reader,代码行数:10,代码来源:test.br-autohelpdesk.php

示例11: unmime

function unmime($s)
{
    // decodage mime (=?iso-8859-1?Q?l=E9a?= et autres =?iso-8859-1?B?bOlh?=)
    $elements = imap_mime_header_decode($s);
    $s = "";
    for ($i = 0; $i < count($elements); $i++) {
        $s .= $elements[$i]->text;
    }
    return $s;
}
开发者ID:BackupTheBerlios,项目名称:oralux,代码行数:10,代码来源:archives-ml.php

示例12: decode

 protected function decode($value)
 {
     $decoded = '';
     $parts = imap_mime_header_decode($value);
     foreach ($parts as $part) {
         $charset = 'default' == $part->charset ? 'auto' : $part->charset;
         // imap_utf8 doesn't seem to work properly, so use Transcoder instead
         $decoded .= Transcoder::create()->transcode($part->text, $charset);
     }
     return $decoded;
 }
开发者ID:voofy,项目名称:imap,代码行数:11,代码来源:Parameters.php

示例13: decode

 /**
  * @param string $text
  * @param string $targetCharset
  *
  * @return string
  */
 public static function decode($text, $targetCharset = 'utf-8')
 {
     if (null === $text) {
         return null;
     }
     $result = '';
     foreach (imap_mime_header_decode($text) as $word) {
         $ch = 'default' === $word->charset ? 'ascii' : $word->charset;
         $result .= Message::charsetConvert($word->text, $ch, $targetCharset) ?: $word->text;
     }
     return $result;
 }
开发者ID:dizews,项目名称:Fetch,代码行数:18,代码来源:MIME.php

示例14: setName

 /**
  * Set email owner name.
  *
  * @param string $name
  */
 public function setName($name)
 {
     if (is_string($name)) {
         $this->raw_name = $name;
         $name = imap_mime_header_decode($name);
         if (empty($name[0])) {
             $this->name = '';
         } else {
             $this->name = $name[0]->text;
         }
     }
 }
开发者ID:komex,项目名称:fetch,代码行数:17,代码来源:Address.php

示例15: decodeMimeStr

function decodeMimeStr($string, $charset = "UTF-8")
{
    $newString = '';
    $elements = imap_mime_header_decode($string);
    for ($i = 0; $i < count($elements); $i++) {
        if ($elements[$i]->charset == 'default' || $elements[$i]->charset == 'x-unknown') {
            $elements[$i]->charset = 'iso-8859-1';
        }
        $newString .= iconv($elements[$i]->charset, $charset, $elements[$i]->text);
    }
    return $newString;
}
开发者ID:palako,项目名称:mobilewebmail,代码行数:12,代码来源:util.php


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