作者 邓超

1

... ... @@ -330,14 +330,27 @@ class Mail {
foreach ($body as $key=>$item){
if(!$description && in_array($item['type']??'',['text/html','text/plain'])){
$value = iconv($item['charset'],'utf-8',$item['body']);
// 是否是base64
$value = @base64_decode($item['body']);
if(!$value){
$value = $item['body'];
}
if(!empty($item['charset'])){
$value = iconv($item['charset'],'utf-8',$value);
}
$value=preg_replace("/<(script.*?)>(.*?)<(\/script.*?)>/si","",$value); //过滤script标签
$value=preg_replace("/<(\/?script.*?)>/si","",$value); //过滤script标签
$value=preg_replace("/javascript/si","Javascript",$value); //过滤script标签
$value=preg_replace("/<(style.*?)>(.*?)<(\/style.*?)>/si","",$value); //过滤style标签
$value=preg_replace("/<(\/?style.*?)>/si","",$value); //过滤style标签
$value = strip_tags($value);
$value = str_replace(["\n",' ',"\\n","&nbsp;"],'',$value);
$description = mb_substr(trim($value),0,190);
}
if(!empty($body[$key]['body'])){
$body[$key]['body'] = base64_encode($body[$key]['body']);
}
... ...