作者 邓超

body

... ... @@ -194,7 +194,7 @@ class Body {
foreach ($this->item as $k=>$item){
if(isset($item['type'])){
//是否有 =E2=81=B6=E2=81=B6=E2=81=B9=C2=B3=C2=B9=C2=B2=C2=BA=C2=B3=C2=BAS 一样的字符
if($item['type']=='text/plain' && preg_match("/(=[A-Z0-9]{2,}){2,}/",$item['body'])){
if(!empty($item['body']) && $item['type']=='text/plain' && preg_match("/(=[A-Z0-9]{2,}){2,}/",$item['body'])){
// 进行解码
$item['body'] = quoted_printable_decode($item['body']);
}
... ... @@ -233,9 +233,9 @@ class Body {
}
// 查找tag块
preg_match_all("/((".str_replace(
['/','+','.','^','$','*','?','|'],
['\/','\+','\.','\^','\$','\*','\?','\|'],
$tag).").*+)/i",$body."\n\n",$he);
['/','+','.','^','$','*','?','|'],
['\/','\+','\.','\^','\$','\*','\?','\|'],
$tag).").*+)/i",$body."\n\n",$he);
// if(error_get_last()){
// logs('body 解析标记 '.$tag."/(".str_replace(['/'],['\/'],$tag).".*+\n)/i".print_r(error_get_last(),true));
... ... @@ -314,8 +314,9 @@ class Body {
$filename = mb_decode_mimeheader($filename[1]);
}
// 附件
if(stripos($item,'Content-Disposition: attachment;')!==false){
if($data['type']=='text/plain' && stripos($item,'Content-Disposition: attachment;')!==false){
$isfileattachment = 1;
$data['append_html'] = 1;
}
... ... @@ -335,16 +336,22 @@ class Body {
// 是文本还是附件
else if(strpos($data['type'],'text/') === 0 ){
$tempbody = trim($this->body_remove_tag($data['body'],'Content-ID:'));
$tempbody = $this->body_remove_tag($tempbody,"Content-");
$tempbody = $this->body_remove_tag($tempbody,"Content-");
$tempbody = $this->body_remove_tag($tempbody,"Content-");
$tempbody = $this->body_remove_tag($tempbody,"Content-");
$tempbody = $this->body_remove_tag($tempbody,"X-OMN-MD5-Sum:");
if(($data['encode']??'')=='base64'){
$tempbody = explode("\r\n\r\n",trim($data['body']));
$tempbody = end($tempbody);
}else{
$tempbody = trim($this->body_remove_tag($data['body'],'Content-ID:'));
$tempbody = $this->body_remove_tag($tempbody,"Content-");
$tempbody = $this->body_remove_tag($tempbody,"Content-");
$tempbody = $this->body_remove_tag($tempbody,"Content-");
$tempbody = $this->body_remove_tag($tempbody,"Content-");
$tempbody = $this->body_remove_tag($tempbody,"X-OMN-MD5-Sum:");
$tempbody = $this->body_remove_tag($tempbody,"X-Attachment-Id:");
}
// 这里还有可能出现附件
if($filename&&!empty($isfileattachment)&&MailFun::isBase64($tempbody)&&$filename!='text_0.txt'){
if($filename&&empty($isfileattachment)){
$data = $this->parseFile($data,$filename);
}else{
// tag
... ... @@ -455,10 +462,10 @@ class Body {
// 找不到后缀,说明不是文件
// if(empty($ext)){
// 文件后缀
// 文件后缀
// $ext = explode('.',$data['filename']);
// $ext = count($ext) > 1 ? ($ext[count($ext)-1]??'') : '';
// 直接返回
// 直接返回
// return $item['body'];
// }
... ... @@ -575,7 +582,7 @@ class Body {
$str = $this->getTag($body,$tag);
// preg_match("/{$tag}\r?[\w\W].*/i",$body,$result);
// if(!empty($result[0])) {
$body = str_replace($str, '', $body);
$body = str_replace($str, '', $body);
// }
return $body;
}
... ...