@@ -386,6 +386,9 @@ private function parseHeader() {
386386 if (property_exists ($ header , 'subject ' )) {
387387 if ($ this ->config ['decoder ' ]['message ' ]['subject ' ] === 'utf-8 ' ) {
388388 $ this ->subject = \imap_utf8 ($ header ->subject );
389+ if (Str::startsWith (mb_strtolower ($ this ->subject ), '=?utf-8? ' )) {
390+ $ this ->subject = mb_decode_mimeheader ($ header ->subject );
391+ }
389392 }elseif ($ this ->config ['decoder ' ]['message ' ]['subject ' ] === 'iconv ' ) {
390393 $ this ->subject = iconv_mime_decode ($ header ->subject );
391394 }else {
@@ -866,13 +869,22 @@ public function convertEncoding($str, $from = "ISO-8859-2", $to = "UTF-8") {
866869 return $ str ;
867870 }
868871
869- if (function_exists ('iconv ' ) && $ from != 'UTF-7 ' && $ to != 'UTF-7 ' ) {
870- return @iconv ($ from , $ to .'//IGNORE ' , $ str );
871- } else {
872- if (!$ from ) {
873- return mb_convert_encoding ($ str , $ to );
872+ try {
873+ if (function_exists ('iconv ' ) && $ from != 'UTF-7 ' && $ to != 'UTF-7 ' ) {
874+ return iconv ($ from , $ to , $ str );
875+ } else {
876+ if (!$ from ) {
877+ return mb_convert_encoding ($ str , $ to );
878+ }
879+ return mb_convert_encoding ($ str , $ to , $ from );
880+ }
881+ } catch (\Exception $ e ) {
882+ if (strstr ($ from , '- ' )) {
883+ $ from = str_replace ('- ' , '' , $ from );
884+ return $ this ->convertEncoding ($ str , $ from , $ to );
885+ } else {
886+ return $ str ;
874887 }
875- return mb_convert_encoding ($ str , $ to , $ from );
876888 }
877889 }
878890
0 commit comments