作者 邓超

m

@@ -21,9 +21,9 @@ class Body { @@ -21,9 +21,9 @@ class Body {
21 21
22 /** 22 /**
23 * 消息结构,解析后的邮件体 header 23 * 消息结构,解析后的邮件体 header
24 - * @var MessageItem 24 + * @var Header
25 */ 25 */
26 - protected MessageItem $msg; 26 + protected Header $header;
27 27
28 28
29 /** 29 /**
@@ -35,22 +35,22 @@ class Body { @@ -35,22 +35,22 @@ class Body {
35 /** 35 /**
36 * Body constructor. 36 * Body constructor.
37 * @param string $result 37 * @param string $result
38 - * @param MessageItem $msg 38 + * @param Header $header
39 */ 39 */
40 - public function __construct(string $result, MessageItem $msg) 40 + public function __construct(string $result, Header $header)
41 { 41 {
42 $this->raw = $result; 42 $this->raw = $result;
43 43
44 - $this->msg = $msg; 44 + $this->header = $header;
45 45
46 46
47 // 是否是多段 47 // 是否是多段
48 - $boundary = $this->msg->header->getBoundary(); 48 + $boundary = $this->header->getBoundary();
49 if($boundary){ 49 if($boundary){
50 $this->parseBoundaryBody($this->raw,$boundary); 50 $this->parseBoundaryBody($this->raw,$boundary);
51 } 51 }
52 // 不是多块级 52 // 不是多块级
53 - if(stripos($this->msg->header->get('content-type'),'text/')===0){ 53 + if(stripos($this->header->get('content-type'),'text/')===0){
54 $this->parseRawHtml($this->raw); 54 $this->parseRawHtml($this->raw);
55 } 55 }
56 56
@@ -85,11 +85,11 @@ class Body { @@ -85,11 +85,11 @@ class Body {
85 */ 85 */
86 private function parseRawHtml(string $raw) { 86 private function parseRawHtml(string $raw) {
87 87
88 - $data = $this->parseMimeHeader('Content-Type: '.$this->msg->header->get('content-type')); 88 + $data = $this->parseMimeHeader('Content-Type: '.$this->header->get('content-type'));
89 89
90 // 设置编码规则 90 // 设置编码规则
91 - if($this->msg->header->get('Content-Transfer-Encoding')){  
92 - $data->set('Content-Transfer-Encoding',$this->msg->header->get('Content-Transfer-Encoding')); 91 + if($this->header->get('Content-Transfer-Encoding')){
  92 + $data->set('Content-Transfer-Encoding',$this->header->get('Content-Transfer-Encoding'));
93 } 93 }
94 94
95 // 是否是item fetch 95 // 是否是item fetch
@@ -163,6 +163,12 @@ class Body { @@ -163,6 +163,12 @@ class Body {
163 case 'base64':{ 163 case 'base64':{
164 $data->body = base64_decode($data->body);break; 164 $data->body = base64_decode($data->body);break;
165 } 165 }
  166 + case 'binary':{
  167 + break;
  168 + }
  169 + case '8bit':{
  170 + break;
  171 + }
166 } 172 }
167 return $data; 173 return $data;
168 } 174 }
@@ -284,6 +290,12 @@ class Body { @@ -284,6 +290,12 @@ class Body {
284 */ 290 */
285 public function getHtmlAndImg():array { 291 public function getHtmlAndImg():array {
286 $html = $this->getHtml(); 292 $html = $this->getHtml();
  293 + $atta = [];
  294 + foreach ($this->items as $item){
  295 + if($item->eq('Content-Disposition','inline')){
  296 + $atta = $item;
  297 + }
  298 + }
287 299
288 } 300 }
289 301
@@ -140,7 +140,7 @@ class Msg extends Request{ @@ -140,7 +140,7 @@ class Msg extends Request{
140 140
141 $this->cmd("UID FETCH %s (RFC822.TEXT)", $msg->uid); 141 $this->cmd("UID FETCH %s (RFC822.TEXT)", $msg->uid);
142 142
143 - return (new ParseBody(implode('',$this->result),$msg)); 143 + return (new ParseBody(implode('',$this->result),$msg->header));
144 144
145 } 145 }
146 146