MailBlack.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Event;
use Model\emailSql;
use Model\folderSql;
use Model\listsSql;
use Swlib\Saber;
use Swlib\SaberGM;
/**
* 黑名单
* @author:dc
* @time 2024/9/30 17:16
* Class MailBlack
* @package Event
*/
class MailBlack {
/**
* @var \Lib\Db|\Lib\DbPool
*/
private $db;
private $blacklist = [];
private $blackFolder = '';
private $data;
public function __construct($id,$data)
{
$data['id'] = $id;
$this->data = $data;
// 读取黑名单
$this->blacklist = redis()->get('blacklist:'.$data['email_id']);
if($this->blacklist){
$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);
}
}
}
}