...
|
...
|
@@ -26,36 +26,6 @@ class MailFun { |
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 解码
|
|
|
* @param $string
|
|
|
* @param string $charset
|
|
|
* @return string
|
|
|
* @time 2022/8/15 9:31
|
|
|
*/
|
|
|
public static function decodeMimeStr($string, $charset = 'utf-8') {
|
|
|
$newString = '';
|
|
|
$elements = \imap_mime_header_decode($string);
|
|
|
// print_r($elements);
|
|
|
for($i = 0; $i < count($elements); $i++) {
|
|
|
if($elements[$i]->charset == 'default') {
|
|
|
$elements[$i]->charset = 'iso-8859-1';
|
|
|
}
|
|
|
$newString .= self::convertStringEncoding($elements[$i]->text, $elements[$i]->charset, $charset);
|
|
|
}
|
|
|
return $newString;
|
|
|
}
|
|
|
|
|
|
public static function convertStringEncoding($string, $fromEncoding, $toEncoding) {
|
|
|
$convertedString = null;
|
|
|
if($string && $fromEncoding != $toEncoding) {
|
|
|
$convertedString = @iconv($fromEncoding, $toEncoding . '//IGNORE', $string);
|
|
|
if(!$convertedString && extension_loaded('mbstring')) {
|
|
|
$convertedString = @mb_convert_encoding($string, $toEncoding, $fromEncoding);
|
|
|
}
|
|
|
}
|
|
|
return $convertedString ?: $string;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|