|
@@ -575,6 +575,15 @@ class Imap { |
|
@@ -575,6 +575,15 @@ class Imap { |
575
|
// 解析header字段
|
575
|
// 解析header字段
|
576
|
foreach ($result as $key=>$item){
|
576
|
foreach ($result as $key=>$item){
|
577
|
$result[$key]['HEADER.FIELDS'] = $this->parseHeader($item['HEADER.FIELDS']);
|
577
|
$result[$key]['HEADER.FIELDS'] = $this->parseHeader($item['HEADER.FIELDS']);
|
|
|
578
|
+ // 编码问题
|
|
|
579
|
+ preg_match('/\("charset" "([a-z0-9\-]{3,})"\)/iU',$result[$key]['BODYSTRUCTURE'],$charset);
|
|
|
580
|
+ // 编码
|
|
|
581
|
+ if(!empty($charset[1])){
|
|
|
582
|
+// $encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'));
|
|
|
583
|
+ $result[$key]['HEADER.FIELDS']['Subject'] = mb_convert_encoding($result[$key]['HEADER.FIELDS']['Subject'], 'UTF-8', $charset[1]);
|
|
|
584
|
+ $result[$key]['HEADER.FIELDS']['From'] = mb_convert_encoding($result[$key]['HEADER.FIELDS']['From'], 'UTF-8', $charset[1]);
|
|
|
585
|
+ $result[$key]['HEADER.FIELDS']['To'] = mb_convert_encoding($result[$key]['HEADER.FIELDS']['To'], 'UTF-8', $charset[1]);
|
|
|
586
|
+ }
|
578
|
}
|
587
|
}
|
579
|
|
588
|
|
580
|
return $result;
|
589
|
return $result;
|