...
|
...
|
@@ -134,13 +134,15 @@ class Body { |
|
|
{
|
|
|
|
|
|
foreach ($this->item as $k=>$item){
|
|
|
//是否有 =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'])){
|
|
|
// 进行解码
|
|
|
$item['body'] = quoted_printable_decode($item['body']);
|
|
|
}
|
|
|
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'])){
|
|
|
// 进行解码
|
|
|
$item['body'] = quoted_printable_decode($item['body']);
|
|
|
}
|
|
|
|
|
|
$this->item[$k] = $item;
|
|
|
$this->item[$k] = $item;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $this->item;
|
...
|
...
|
@@ -200,9 +202,9 @@ class Body { |
|
|
if(!$item) { continue; }
|
|
|
|
|
|
// 邮件体包含邮件体
|
|
|
if(preg_match("/boundary=\"(.*)\"/Ui",$item,$bm)){
|
|
|
if(preg_match('/boundary="?(.*)("|\r)/i',$item,$bm)){
|
|
|
|
|
|
if (strpos($item,$bm[1].'--')!==false){
|
|
|
if (str_contains($item, trim($bm[1]).'--')){
|
|
|
$data = (new self('--'.$bm[1]."\r\n".$item,$this->fileSavePath))->getItem();
|
|
|
// $this->setItem($data);
|
|
|
// 合并邮件体
|
...
|
...
|
@@ -379,7 +381,9 @@ class Body { |
|
|
|
|
|
|
|
|
// content id
|
|
|
preg_match("/Content-ID:[\s].*<[\w\W]{1,}>/i",$item['body'],$result);
|
|
|
// preg_match("/Content-ID:[\s].*<[\w\W]{1,}>/i",$item['body'],$result);
|
|
|
|
|
|
$result[0] = $this->getTag($item['body'],'Content-ID:');
|
|
|
if (!empty($result[0])){
|
|
|
$data['content-id'] = explode('<',$result[0]);
|
|
|
$data['content-id'] = $data['content-id'][1];
|
...
|
...
|
@@ -426,6 +430,39 @@ class Body { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取某个tag
|
|
|
* @param $content
|
|
|
* @param $tag
|
|
|
* @return string
|
|
|
* @author:dc
|
|
|
* @time 2023/10/30 22:45
|
|
|
*/
|
|
|
public function getTag($content,$tag){
|
|
|
$items = explode("\n",$content);
|
|
|
$ctstr = '';
|
|
|
foreach ($items as $str){
|
|
|
if($ctstr){
|
|
|
|
|
|
if(empty(trim($str))){
|
|
|
break;
|
|
|
}
|
|
|
if(str_starts_with($str, "\t")||str_starts_with($str, " ")){
|
|
|
$ctstr .= $str."\n";
|
|
|
}else{
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(str_starts_with(strtolower($str), strtolower($tag))){
|
|
|
$ctstr .= $str."\n";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return trim($ctstr);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除tag
|
|
|
* @param $body
|
|
|
* @param $tag
|
...
|
...
|
@@ -434,10 +471,11 @@ class Body { |
|
|
* @time 2022/8/12 10:34
|
|
|
*/
|
|
|
private function body_remove_tag($body,$tag){
|
|
|
preg_match("/{$tag}\r?[\w\W].*/i",$body,$result);
|
|
|
if(!empty($result[0])) {
|
|
|
$body = str_replace($result, '', $body);
|
|
|
}
|
|
|
$str = $this->getTag($body,$tag);
|
|
|
// preg_match("/{$tag}\r?[\w\W].*/i",$body,$result);
|
|
|
// if(!empty($result[0])) {
|
|
|
$body = str_replace($str, '', $body);
|
|
|
// }
|
|
|
return $body;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -470,9 +508,27 @@ class Body { |
|
|
* @time 2022/8/12 10:26
|
|
|
*/
|
|
|
private function preg_match_type($item){
|
|
|
// 匹配内容 type
|
|
|
preg_match("/Content-Type:[\w\W].*/i",$item,$result);
|
|
|
$items = explode("\n",$item);
|
|
|
$ctstr = '';
|
|
|
foreach ($items as $str){
|
|
|
if($ctstr){
|
|
|
|
|
|
if(str_starts_with($str, "\t")){
|
|
|
$ctstr .= $str."\n";
|
|
|
}else{
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(str_starts_with($str, 'Content-Type:')){
|
|
|
$ctstr .= $str."\n";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 匹配内容 type
|
|
|
// preg_match("/Content-Type:[\w\W].*/i",$item,$result);
|
|
|
$result[0] = $ctstr;
|
|
|
if(!empty($result[0])){
|
|
|
$ret['origin'] = trim($result[0]);
|
|
|
// type
|
...
|
...
|
|