正在显示
1 个修改的文件
包含
23 行增加
和
16 行删除
| @@ -194,7 +194,7 @@ class Body { | @@ -194,7 +194,7 @@ class Body { | ||
| 194 | foreach ($this->item as $k=>$item){ | 194 | foreach ($this->item as $k=>$item){ | 
| 195 | if(isset($item['type'])){ | 195 | if(isset($item['type'])){ | 
| 196 | //是否有 =E2=81=B6=E2=81=B6=E2=81=B9=C2=B3=C2=B9=C2=B2=C2=BA=C2=B3=C2=BAS 一样的字符 | 196 | //是否有 =E2=81=B6=E2=81=B6=E2=81=B9=C2=B3=C2=B9=C2=B2=C2=BA=C2=B3=C2=BAS 一样的字符 | 
| 197 | - if($item['type']=='text/plain' && preg_match("/(=[A-Z0-9]{2,}){2,}/",$item['body'])){ | 197 | + if(!empty($item['body']) && $item['type']=='text/plain' && preg_match("/(=[A-Z0-9]{2,}){2,}/",$item['body'])){ | 
| 198 | // 进行解码 | 198 | // 进行解码 | 
| 199 | $item['body'] = quoted_printable_decode($item['body']); | 199 | $item['body'] = quoted_printable_decode($item['body']); | 
| 200 | } | 200 | } | 
| @@ -233,9 +233,9 @@ class Body { | @@ -233,9 +233,9 @@ class Body { | ||
| 233 | } | 233 | } | 
| 234 | // 查找tag块 | 234 | // 查找tag块 | 
| 235 | preg_match_all("/((".str_replace( | 235 | preg_match_all("/((".str_replace( | 
| 236 | - ['/','+','.','^','$','*','?','|'], | ||
| 237 | - ['\/','\+','\.','\^','\$','\*','\?','\|'], | ||
| 238 | - $tag).").*+)/i",$body."\n\n",$he); | 236 | + ['/','+','.','^','$','*','?','|'], | 
| 237 | + ['\/','\+','\.','\^','\$','\*','\?','\|'], | ||
| 238 | + $tag).").*+)/i",$body."\n\n",$he); | ||
| 239 | 239 | ||
| 240 | // if(error_get_last()){ | 240 | // if(error_get_last()){ | 
| 241 | // logs('body 解析标记 '.$tag."/(".str_replace(['/'],['\/'],$tag).".*+\n)/i".print_r(error_get_last(),true)); | 241 | // logs('body 解析标记 '.$tag."/(".str_replace(['/'],['\/'],$tag).".*+\n)/i".print_r(error_get_last(),true)); | 
| @@ -314,8 +314,9 @@ class Body { | @@ -314,8 +314,9 @@ class Body { | ||
| 314 | $filename = mb_decode_mimeheader($filename[1]); | 314 | $filename = mb_decode_mimeheader($filename[1]); | 
| 315 | } | 315 | } | 
| 316 | // 附件 | 316 | // 附件 | 
| 317 | - if(stripos($item,'Content-Disposition: attachment;')!==false){ | 317 | + if($data['type']=='text/plain' && stripos($item,'Content-Disposition: attachment;')!==false){ | 
| 318 | $isfileattachment = 1; | 318 | $isfileattachment = 1; | 
| 319 | + $data['append_html'] = 1; | ||
| 319 | } | 320 | } | 
| 320 | 321 | ||
| 321 | 322 | ||
| @@ -335,16 +336,22 @@ class Body { | @@ -335,16 +336,22 @@ class Body { | ||
| 335 | // 是文本还是附件 | 336 | // 是文本还是附件 | 
| 336 | else if(strpos($data['type'],'text/') === 0 ){ | 337 | else if(strpos($data['type'],'text/') === 0 ){ | 
| 337 | 338 | ||
| 338 | - $tempbody = trim($this->body_remove_tag($data['body'],'Content-ID:')); | ||
| 339 | - | ||
| 340 | - $tempbody = $this->body_remove_tag($tempbody,"Content-"); | ||
| 341 | - $tempbody = $this->body_remove_tag($tempbody,"Content-"); | ||
| 342 | - $tempbody = $this->body_remove_tag($tempbody,"Content-"); | ||
| 343 | - $tempbody = $this->body_remove_tag($tempbody,"Content-"); | ||
| 344 | - $tempbody = $this->body_remove_tag($tempbody,"X-OMN-MD5-Sum:"); | 339 | + if(($data['encode']??'')=='base64'){ | 
| 340 | + $tempbody = explode("\r\n\r\n",trim($data['body'])); | ||
| 341 | + $tempbody = end($tempbody); | ||
| 342 | + }else{ | ||
| 343 | + $tempbody = trim($this->body_remove_tag($data['body'],'Content-ID:')); | ||
| 344 | + | ||
| 345 | + $tempbody = $this->body_remove_tag($tempbody,"Content-"); | ||
| 346 | + $tempbody = $this->body_remove_tag($tempbody,"Content-"); | ||
| 347 | + $tempbody = $this->body_remove_tag($tempbody,"Content-"); | ||
| 348 | + $tempbody = $this->body_remove_tag($tempbody,"Content-"); | ||
| 349 | + $tempbody = $this->body_remove_tag($tempbody,"X-OMN-MD5-Sum:"); | ||
| 350 | + $tempbody = $this->body_remove_tag($tempbody,"X-Attachment-Id:"); | ||
| 351 | + } | ||
| 345 | 352 | ||
| 346 | // 这里还有可能出现附件 | 353 | // 这里还有可能出现附件 | 
| 347 | - if($filename&&!empty($isfileattachment)&&MailFun::isBase64($tempbody)&&$filename!='text_0.txt'){ | 354 | + if($filename&&empty($isfileattachment)){ | 
| 348 | $data = $this->parseFile($data,$filename); | 355 | $data = $this->parseFile($data,$filename); | 
| 349 | }else{ | 356 | }else{ | 
| 350 | // tag | 357 | // tag | 
| @@ -455,10 +462,10 @@ class Body { | @@ -455,10 +462,10 @@ class Body { | ||
| 455 | 462 | ||
| 456 | // 找不到后缀,说明不是文件 | 463 | // 找不到后缀,说明不是文件 | 
| 457 | // if(empty($ext)){ | 464 | // if(empty($ext)){ | 
| 458 | - // 文件后缀 | 465 | + // 文件后缀 | 
| 459 | // $ext = explode('.',$data['filename']); | 466 | // $ext = explode('.',$data['filename']); | 
| 460 | // $ext = count($ext) > 1 ? ($ext[count($ext)-1]??'') : ''; | 467 | // $ext = count($ext) > 1 ? ($ext[count($ext)-1]??'') : ''; | 
| 461 | - // 直接返回 | 468 | + // 直接返回 | 
| 462 | // return $item['body']; | 469 | // return $item['body']; | 
| 463 | // } | 470 | // } | 
| 464 | 471 | ||
| @@ -575,7 +582,7 @@ class Body { | @@ -575,7 +582,7 @@ class Body { | ||
| 575 | $str = $this->getTag($body,$tag); | 582 | $str = $this->getTag($body,$tag); | 
| 576 | // preg_match("/{$tag}\r?[\w\W].*/i",$body,$result); | 583 | // preg_match("/{$tag}\r?[\w\W].*/i",$body,$result); | 
| 577 | // if(!empty($result[0])) { | 584 | // if(!empty($result[0])) { | 
| 578 | - $body = str_replace($str, '', $body); | 585 | + $body = str_replace($str, '', $body); | 
| 579 | // } | 586 | // } | 
| 580 | return $body; | 587 | return $body; | 
| 581 | } | 588 | } | 
- 
请 注册 或 登录 后发表评论