正在显示
3 个修改的文件
包含
26 行增加
和
10 行删除
@@ -579,11 +579,16 @@ class Imap { | @@ -579,11 +579,16 @@ class Imap { | ||
579 | preg_match('/\("charset" "([a-z0-9\-]{3,})"\)/iU',$result[$key]['BODYSTRUCTURE'],$charset); | 579 | preg_match('/\("charset" "([a-z0-9\-]{3,})"\)/iU',$result[$key]['BODYSTRUCTURE'],$charset); |
580 | // 编码 | 580 | // 编码 |
581 | if(!empty($charset[1])){ | 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]); | 582 | + $charset = [$charset[1]]; |
583 | + }else{ | ||
584 | + $charset = []; | ||
586 | } | 585 | } |
586 | + | ||
587 | + | ||
588 | + $result[$key]['HEADER.FIELDS']['Subject'] = MailFun::mb_coding($result[$key]['HEADER.FIELDS']['Subject'],$charset); | ||
589 | + $result[$key]['HEADER.FIELDS']['From'] = MailFun::mb_coding($result[$key]['HEADER.FIELDS']['From'],$charset); | ||
590 | + $result[$key]['HEADER.FIELDS']['To'] = MailFun::mb_coding($result[$key]['HEADER.FIELDS']['To'],$charset); | ||
591 | + | ||
587 | } | 592 | } |
588 | 593 | ||
589 | return $result; | 594 | return $result; |
@@ -200,8 +200,6 @@ class Mail { | @@ -200,8 +200,6 @@ class Mail { | ||
200 | } | 200 | } |
201 | try { | 201 | try { |
202 | 202 | ||
203 | - $file_header = $result['BODYSTRUCTURE']; | ||
204 | - | ||
205 | // 没有收件人 | 203 | // 没有收件人 |
206 | if(!empty($header['To'])){ | 204 | if(!empty($header['To'])){ |
207 | $header['To'] = MailFun::toOrFrom($header['To']); | 205 | $header['To'] = MailFun::toOrFrom($header['To']); |
@@ -233,7 +231,7 @@ class Mail { | @@ -233,7 +231,7 @@ class Mail { | ||
233 | 'folder_id' => $folder_id, | 231 | 'folder_id' => $folder_id, |
234 | 'email_id' => $email_id, | 232 | 'email_id' => $email_id, |
235 | 'uuid' => md5($email_id.$folder_id.$result['UID']), | 233 | 'uuid' => md5($email_id.$folder_id.$result['UID']), |
236 | - 'is_file' => MailFun::isFile($file_header[$key]['BODYSTRUCTURE']??'') //是否附件 | 234 | + 'is_file' => MailFun::isFile($result['BODYSTRUCTURE']??'') //是否附件 |
237 | ]; | 235 | ]; |
238 | }catch (\Throwable $e){ | 236 | }catch (\Throwable $e){ |
239 | logs( | 237 | logs( |
@@ -25,7 +25,20 @@ class MailFun { | @@ -25,7 +25,20 @@ class MailFun { | ||
25 | return \json_encode($data,$option); | 25 | return \json_encode($data,$option); |
26 | } | 26 | } |
27 | 27 | ||
28 | - | 28 | + /** |
29 | + * @param $str | ||
30 | + * @param string $encode | ||
31 | + * @return string | ||
32 | + * @author:dc | ||
33 | + * @time 2023/3/27 13:55 | ||
34 | + */ | ||
35 | + public static function mb_coding(string $str,array $appcode=[]){ | ||
36 | + $encode = mb_detect_encoding($str, array_merge(array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'),$appcode)); | ||
37 | + if($encode){ | ||
38 | + return mb_convert_encoding($str, 'UTF-8', $encode); | ||
39 | + } | ||
40 | + return $str; | ||
41 | + } | ||
29 | 42 | ||
30 | 43 | ||
31 | /** | 44 | /** |
@@ -42,8 +55,8 @@ class MailFun { | @@ -42,8 +55,8 @@ class MailFun { | ||
42 | // } | 55 | // } |
43 | // } | 56 | // } |
44 | // return 0; | 57 | // return 0; |
45 | - $json = is_array($BODYSTRUCTURE) ? json_encode($BODYSTRUCTURE) : $BODYSTRUCTURE; | ||
46 | - return strpos($json,'"attachment"')!==false; | 58 | + $json = is_array($BODYSTRUCTURE) ? implode(' ',$BODYSTRUCTURE) : $BODYSTRUCTURE; |
59 | + return str_contains(mb_strtolower($json), '"attachment"'); | ||
47 | } | 60 | } |
48 | 61 | ||
49 | 62 |
-
请 注册 或 登录 后发表评论