|
@@ -26,36 +26,6 @@ class MailFun { |
|
@@ -26,36 +26,6 @@ class MailFun { |
26
|
}
|
26
|
}
|
27
|
|
27
|
|
28
|
|
28
|
|
29
|
- /**
|
|
|
30
|
- * 解码
|
|
|
31
|
- * @param $string
|
|
|
32
|
- * @param string $charset
|
|
|
33
|
- * @return string
|
|
|
34
|
- * @time 2022/8/15 9:31
|
|
|
35
|
- */
|
|
|
36
|
- public static function decodeMimeStr($string, $charset = 'utf-8') {
|
|
|
37
|
- $newString = '';
|
|
|
38
|
- $elements = \imap_mime_header_decode($string);
|
|
|
39
|
-// print_r($elements);
|
|
|
40
|
- for($i = 0; $i < count($elements); $i++) {
|
|
|
41
|
- if($elements[$i]->charset == 'default') {
|
|
|
42
|
- $elements[$i]->charset = 'iso-8859-1';
|
|
|
43
|
- }
|
|
|
44
|
- $newString .= self::convertStringEncoding($elements[$i]->text, $elements[$i]->charset, $charset);
|
|
|
45
|
- }
|
|
|
46
|
- return $newString;
|
|
|
47
|
- }
|
|
|
48
|
-
|
|
|
49
|
- public static function convertStringEncoding($string, $fromEncoding, $toEncoding) {
|
|
|
50
|
- $convertedString = null;
|
|
|
51
|
- if($string && $fromEncoding != $toEncoding) {
|
|
|
52
|
- $convertedString = @iconv($fromEncoding, $toEncoding . '//IGNORE', $string);
|
|
|
53
|
- if(!$convertedString && extension_loaded('mbstring')) {
|
|
|
54
|
- $convertedString = @mb_convert_encoding($string, $toEncoding, $fromEncoding);
|
|
|
55
|
- }
|
|
|
56
|
- }
|
|
|
57
|
- return $convertedString ?: $string;
|
|
|
58
|
- }
|
|
|
59
|
|
29
|
|
60
|
|
30
|
|
61
|
/**
|
31
|
/**
|