作者 邓超

1

... ... @@ -227,7 +227,8 @@ class Body {
// 先匹配留存文件名称
preg_match('/filename="(\w?.*)"/',$item,$filename);
if(!empty($filename[1])){
$filename = MailFun::decodeMimeStr($filename[1]);
// $filename = MailFun::decodeMimeStr($filename[1]);
$filename = mb_decode_mimeheader($filename[1]);
}
... ...
... ... @@ -575,6 +575,15 @@ class Imap {
// 解析header字段
foreach ($result as $key=>$item){
$result[$key]['HEADER.FIELDS'] = $this->parseHeader($item['HEADER.FIELDS']);
// 编码问题
preg_match('/\("charset" "([a-z0-9\-]{3,})"\)/iU',$result[$key]['BODYSTRUCTURE'],$charset);
// 编码
if(!empty($charset[1])){
// $encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'));
$result[$key]['HEADER.FIELDS']['Subject'] = mb_convert_encoding($result[$key]['HEADER.FIELDS']['Subject'], 'UTF-8', $charset[1]);
$result[$key]['HEADER.FIELDS']['From'] = mb_convert_encoding($result[$key]['HEADER.FIELDS']['From'], 'UTF-8', $charset[1]);
$result[$key]['HEADER.FIELDS']['To'] = mb_convert_encoding($result[$key]['HEADER.FIELDS']['To'], 'UTF-8', $charset[1]);
}
}
return $result;
... ...