• 解决php收邮件乱码问题


    function test($strHead){   
    if(ereg("=?.{0,}?[Bb]?",$strHead)){   
      $arrHead=split("=?.{0,}?[Bb]?",$strHead);   
      while(list($key,$value)=each($arrHead)){   
        if(ereg("?=",$value)){   
          $arrTemp=split("?=",$value);   
          $arrTemp[0]=base64_decode($arrTemp[0]);   
          $arrHead[$key]=join("",$arrTemp);   
        }   
      }   
      $strHead=join("",$arrHead);   
    }   
      return $strHead;   
    }   
    
    function is_utf8($string) {  
          
        // From http://w3.org/International/questions/qa-forms-utf-8.html  
        return preg_match('%^(?:  
              [x09x0Ax0Dx20-x7E]            # ASCII  
            | [xC2-xDF][x80-xBF]             # non-overlong 2-byte  
            |  xE0[xA0-xBF][x80-xBF]        # excluding overlongs  
            | [xE1-xECxEExEF][x80-xBF]{2}  # straight 3-byte  
            |  xED[x80-x9F][x80-xBF]        # excluding surrogates  
            |  xF0[x90-xBF][x80-xBF]{2}     # planes 1-3  
            | [xF1-xF3][x80-xBF]{3}          # planes 4-15  
            |  xF4[x80-x8F][x80-xBF]{2}     # plane 16  
        )*$%xs', $string);  
          
    }  
    
    
    for($i=$tot;$i>0;$i--)
    {
    	$head=$obj->getHeaders($i);  // Get Header Info Return Array Of Headers **Array Keys are (subject,to,toOth,toNameOth,from,fromName)
    	//echo "Subjects :: ".$head['subject']."<br>";
    	 $s=test($head['subject']);  
        if(is_utf8($s)=='1'){  
        echo iconv('UTF-8','gb2312',$s) ;   
        }else{  
            echo $s;  
        }  
        echo "<br>";  
    	echo "base :: ".iconv("GB2312", "utf-8", base64_decode('5rWL6K+V'))."<br>";
    	echo "TO :: ".$head['to']."<br>";
    	echo "To Other :: ".$head['toOth']."<br>";
    	echo "ToName Other :: ".$head['toNameOth']."<br>";
    	echo "From :: ".$head['from']."<br>";
    	echo "FromName :: ".$head['fromName']."<br>";
    	echo "<br><br>";
    	echo "<br>*******************************************************************************************<BR>";
    	echo $obj->getBody($i);  // Get Body Of Mail number Return String Get Mail id in interger
    	
    	$str=$obj->GetAttach($i,"./"); // Get attached File from Mail Return name of file in comma separated string  args. (mailid, Path to store file)
    	$ar=explode(",",$str);
    	foreach($ar as $key=>$value)
    		echo ($value=="")?"":"Atteched File :: ".$value."<br>";
    	echo "<br>------------------------------------------------------------------------------------------<BR>";
    	
    	//$obj->deleteMails($i); // Delete Mail from Mail box
    }
    

     imap_append :     附加字符串到指定的邮箱中。
    imap_base64 :     解 base64 编码。
    imap_body :     读信的内文。
    imap_check :     返回邮箱信息。
    imap_close :     关闭 imap 链接。
    imap_createmailbox :     建立新的信箱。
    imap_delete :     标记欲删除邮件。
    imap_deletemailbox :     删除既有信箱。
    imap_expunge :     删除已标记的邮件。
    imap_fetchbody :     从信件内文取出指定部分。
    imap_fetchstructure :     获取某信件的结构信息。
    imap_header :     获取某信件的标头信息。
    imap_headers :     获取全部信件的标头信息。
    imap_listmailbox :     获取邮箱列示。
    imap_listsubscribed :     获取订阅邮箱列示。
    imap_mail_copy :     复制指定信件到它处邮箱。
    imap_mail_move :     移动指定信件到它处邮箱。
    imap_num_msg :     取得信件数。
    imap_num_recent :     取得新进信件数。

    imap_open :     打开 imap 链接。
    imap_ping :     检查 imap 是否连接。
    imap_renamemailbox :     更改邮箱名字。
    imap_reopen :     重开 imap 链接。
    imap_subscribe :     订阅邮箱。
    imap_undelete :     取消删除邮件标记。
    imap_unsubscribe :     取消订阅邮箱。
    imap_qprint :     将 qp 编码转成八位。
    imap_8bit :     将八位转成 qp 编码。
    imap_binary :     将八位转成 base64 编码。
    imap_scanmailbox :     寻找信件有无特定字符串。
    imap_mailboxmsginfo :     取得目前邮箱的信息。
    imap_rfc822_write_address :     电子邮件位址标准化。
    imap_rfc822_parse_adrlist :     解析电子邮件位址。
    imap_setflag_full :     配置信件标志。
    imap_clearflag_full :     清除信件标志。
    imap_sort :     将信件标头排序。
    imap_fetchheader :     取得原始标头。
    imap_uid :     取得信件 uid。
    imap_getmailboxes :     取得全部信件详细信息。
    imap_getsubscribed :     列出所有订阅邮箱。
    imap_msgno :     列出 uid 的连续信件。
    imap_search :     搜寻指定标准的信件。
    imap_last_error :     最后的错误信息。
    imap_errors :     所有的错误信息。
    imap_alerts :     所有的警告信息。
    imap_status :     目前的状态信息。

  • 相关阅读:
    但是难道我就不能在JBuilder里面看我可爱的中文了吗?[小糊涂的灵感]
    why is j2me midp superior to wap?[小糊涂的灵感]
    NRF51822之GPIOTE介绍
    Unity脚本生命周期
    树状数组学习笔记
    模版—扩展欧几里德
    hdu4339Query
    POJ3273Monthly Expense
    多校第一场
    ZOJJ Watashi's BG3631
  • 原文地址:https://www.cnblogs.com/wpcnblog/p/3591300.html
Copyright © 2020-2023  润新知