| 
...
 | 
...
 | 
@@ -106,18 +106,19 @@ class Header{ | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     /**
 | 
| 
 | 
 | 
      * 读取字段
 | 
| 
 | 
 | 
      * @param string $name
 | 
| 
 | 
 | 
      * @param string $name 字段名称
 | 
| 
 | 
 | 
      * @param mixed ...$params 额外参数
 | 
| 
 | 
 | 
      * @return mixed
 | 
| 
 | 
 | 
      * @author:dc
 | 
| 
 | 
 | 
      * @time 2024/9/11 15:06
 | 
| 
 | 
 | 
      * @time 2024/12/11 11:50
 | 
| 
 | 
 | 
      */
 | 
| 
 | 
 | 
     public function get(string $name):mixed {
 | 
| 
 | 
 | 
     public function get(string $name,...$params):mixed {
 | 
| 
 | 
 | 
         $name = strtolower($name);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $m = 'get'.str_replace(' ','',ucwords(str_replace('-',' ',$name)));
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         if(method_exists($this,$m)){
 | 
| 
 | 
 | 
             return $this->{$m}();
 | 
| 
 | 
 | 
             return $this->{$m}(...$params);
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         return $this->attributes[$name]??'';
 | 
| 
...
 | 
...
 | 
@@ -192,15 +193,19 @@ class Header{ | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     /**
 | 
| 
 | 
 | 
      * 发件人 可能是欺炸 发件人
 | 
| 
 | 
 | 
      * @return Address
 | 
| 
 | 
 | 
      * @param bool $isArray 是否返回数组
 | 
| 
 | 
 | 
      * @return Address|array
 | 
| 
 | 
 | 
      * @author:dc
 | 
| 
 | 
 | 
      * @time 2024/9/11 15:19
 | 
| 
 | 
 | 
      * @time 2024/12/11 11:52
 | 
| 
 | 
 | 
      */
 | 
| 
 | 
 | 
     public function getFrom():Address {
 | 
| 
 | 
 | 
         return Address::make($this->attributes['from']??'');
 | 
| 
 | 
 | 
     public function getFrom(bool $isArray = false):Address|array {
 | 
| 
 | 
 | 
         $address = Address::make($this->attributes['from']??'');
 | 
| 
 | 
 | 
         if($isArray){
 | 
| 
 | 
 | 
             return $address->toArray();
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
         return $address;
 | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     /**
 | 
| 
...
 | 
...
 | 
@@ -274,7 +279,7 @@ class Header{ | 
| 
 | 
 | 
     public function toArray():array {
 | 
| 
 | 
 | 
         $arr = [];
 | 
| 
 | 
 | 
         foreach ($this->attributes as $key=>$attr){
 | 
| 
 | 
 | 
             $arr[$key] = $this->get($key);
 | 
| 
 | 
 | 
             $arr[$key] = $this->get($key,true);
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         return $arr;
 | 
| 
...
 | 
...
 | 
@@ -300,24 +305,21 @@ class Header{ | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $str = trim($str);
 | 
| 
 | 
 | 
         $str = explode("\r\n",$str);
 | 
| 
 | 
 | 
         foreach ($str as $k=>$s){
 | 
| 
 | 
 | 
             $s = trim($s);
 | 
| 
 | 
 | 
             if(preg_match("/^=\?([a-z0-9-.]{3,})\?[bq]\?/i",$s,$code)){
 | 
| 
 | 
 | 
         $str = implode('',$str);
 | 
| 
 | 
 | 
         preg_match_all("/=\?[a-z0-9-.]{3,}\?[bq]\?.*\?=$/Ui",$str,$codes);
 | 
| 
 | 
 | 
         foreach ($codes[0] as $c){
 | 
| 
 | 
 | 
             if(preg_match("/^=\?([a-z0-9-.]{3,})\?[bq]\?.*\?=$/i",$c,$cc)){
 | 
| 
 | 
 | 
                 // 解码 这个函数好像已经转码了,
 | 
| 
 | 
 | 
 //            iso-8859-8-i php 好像没有这个编码 ,阿拉伯 iso-8859-8
 | 
| 
 | 
 | 
 //            =?iso-8859-8-i?B?4eTu+eog7PTw6en66iDg7CDn4fj6IERjb20gLSD08OnkIO7xIDgyNzUz?=
 | 
| 
 | 
 | 
                 $s = str_replace("=?{$code[1]}?",'=?'.Fun::getEncodingAliases($code[1]).'?',$s);
 | 
| 
 | 
 | 
                 $s = str_replace("=?{$cc[1]}?",'=?'.Fun::getEncodingAliases($cc[1]).'?',$c);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
                 $s = mb_decode_mimeheader($s);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
                 $str[$k] = $s;
 | 
| 
 | 
 | 
                 // 转字符编码
 | 
| 
 | 
 | 
 //            return mb_convert_encoding($str,'utf-8',$code[1]);
 | 
| 
 | 
 | 
                 $str = str_replace($c,$s,$str);
 | 
| 
 | 
 | 
             }
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         return implode(" ",$str);
 | 
| 
 | 
 | 
         return $str;
 | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
 
 | 
...
 | 
...
 | 
 |