作者 邓超

x

@@ -41,12 +41,31 @@ class MailBlack { @@ -41,12 +41,31 @@ class MailBlack {
41 $this->blackFolder = $this->db->cache(3600)->value(folderSql::originFolder($data['email_id'],'垃圾箱')); 41 $this->blackFolder = $this->db->cache(3600)->value(folderSql::originFolder($data['email_id'],'垃圾箱'));
42 } 42 }
43 43
  44 + $this->check();
44 45
  46 + }
45 47
46 48
  49 + protected function check(){
47 50
  51 + // 验证是否存在黑名单中
  52 + if($this->blacklist && $this->blackFolder != $folder){
  53 + // 邮箱是否在黑名单中
  54 + $isBlacklist = false;
  55 + if (!empty($blacklist['emails']) && is_array($blacklist['emails']) && in_array($this->data['from'],$blacklist['emails'])){
  56 + $isBlacklist = true;
  57 + }
  58 + // 域是否存在
  59 + if (!empty($blacklist['domain']) && is_array($blacklist['domain']) && in_array(explode('@',$this->data['from'])[1],$blacklist['domain'])){
  60 + $isBlacklist = true;
  61 + }
48 62
  63 + if($isBlacklist && $this->blackFolder){
  64 + // 移入垃圾箱
  65 + $this->client->move([$this->data['uid']],$this->blackFolder);
  66 + }
49 } 67 }
50 68
  69 + }
51 70
52 } 71 }
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace Lib\Mail; 3 namespace Lib\Mail;
4 4
  5 +use Event\Event;
5 use Event\syncMail; 6 use Event\syncMail;
6 use Lib\DbPool; 7 use Lib\DbPool;
7 use Model\bodySql; 8 use Model\bodySql;
@@ -442,13 +443,7 @@ class Mail { @@ -442,13 +443,7 @@ class Mail {
442 try { 443 try {
443 $id = $db->throw()->insert(listsSql::$table,$data); 444 $id = $db->throw()->insert(listsSql::$table,$data);
444 if($id){ 445 if($id){
445 - if(php_sapi_name()=='cli'){  
446 - go(function ($id,$header,$data){  
447 - new syncMail($id,$header,$data);  
448 - },  
449 - ...[$id,$header,$data]  
450 - );  
451 - } 446 + Event::call(SyncMail::class,$id,$data);
452 } 447 }
453 448
454 }catch (\Throwable $e){ 449 }catch (\Throwable $e){