作者 邓超

x

@@ -37,7 +37,9 @@ class MailFun { @@ -37,7 +37,9 @@ class MailFun {
37 * @time 2023/3/27 13:55 37 * @time 2023/3/27 13:55
38 */ 38 */
39 public static function mb_coding(string $str,array $appcode=[]){ 39 public static function mb_coding(string $str,array $appcode=[]){
40 - $str = (new Header())->decode(trim($str," \t\n\r")); 40 + $str = trim($str," \t\n\r");
  41 + preg_match("/^=\?(.*)\?/U",$str,$code);
  42 + $str = (new Header())->decode($str);
41 // if(str_starts_with($str, '=?')){ 43 // if(str_starts_with($str, '=?')){
42 // try { 44 // try {
43 // $encode = @mb_detect_encoding($str, array_merge(array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'),$appcode)); 45 // $encode = @mb_detect_encoding($str, array_merge(array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'),$appcode));
@@ -48,6 +50,9 @@ class MailFun { @@ -48,6 +50,9 @@ class MailFun {
48 // 50 //
49 // } 51 // }
50 // } 52 // }
  53 + if(($code[1]??'utf-8') != 'utf-8'){
  54 + $str = mb_convert_encoding($str, 'UTF-8', $code[1]);
  55 + }
51 56
52 return $str; 57 return $str;
53 } 58 }