作者 邓超

x

... ... @@ -41,12 +41,31 @@ class MailBlack {
$this->blackFolder = $this->db->cache(3600)->value(folderSql::originFolder($data['email_id'],'垃圾箱'));
}
$this->check();
}
protected function check(){
// 验证是否存在黑名单中
if($this->blacklist && $this->blackFolder != $folder){
// 邮箱是否在黑名单中
$isBlacklist = false;
if (!empty($blacklist['emails']) && is_array($blacklist['emails']) && in_array($this->data['from'],$blacklist['emails'])){
$isBlacklist = true;
}
// 域是否存在
if (!empty($blacklist['domain']) && is_array($blacklist['domain']) && in_array(explode('@',$this->data['from'])[1],$blacklist['domain'])){
$isBlacklist = true;
}
if($isBlacklist && $this->blackFolder){
// 移入垃圾箱
$this->client->move([$this->data['uid']],$this->blackFolder);
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@
namespace Lib\Mail;
use Event\Event;
use Event\syncMail;
use Lib\DbPool;
use Model\bodySql;
... ... @@ -442,13 +443,7 @@ class Mail {
try {
$id = $db->throw()->insert(listsSql::$table,$data);
if($id){
if(php_sapi_name()=='cli'){
go(function ($id,$header,$data){
new syncMail($id,$header,$data);
},
...[$id,$header,$data]
);
}
Event::call(SyncMail::class,$id,$data);
}
}catch (\Throwable $e){
... ...