1
|
<?php
|
1
|
<?php
|
2
|
|
2
|
|
3
|
|
3
|
|
|
|
4
|
+use Model\folderSql;
|
|
|
5
|
+
|
4
|
require_once "../vendor/autoload.php";
|
6
|
require_once "../vendor/autoload.php";
|
5
|
|
7
|
|
6
|
|
8
|
|
|
@@ -81,19 +83,36 @@ class fob_ai_mail_auto_reply { |
|
@@ -81,19 +83,36 @@ class fob_ai_mail_auto_reply { |
81
|
continue;
|
83
|
continue;
|
82
|
}
|
84
|
}
|
83
|
// 查询数据
|
85
|
// 查询数据
|
84
|
- $data = $this->db->throw()->first(\Model\listsSql::first('`id` = '.$did,'`id`,`folder_id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`to`'));
|
86
|
+ $data = $this->db->throw()->first(\Model\listsSql::first('`id` = '.$did,'`id`,`folder_id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`to`,`uid`'));
|
85
|
if($data && !$data['is_hots']){
|
87
|
if($data && !$data['is_hots']){
|
86
|
|
88
|
|
87
|
// 不是屏蔽的
|
89
|
// 不是屏蔽的
|
88
|
$body = getBodyHtml(getMailBody($data['id']));
|
90
|
$body = getBodyHtml(getMailBody($data['id']));
|
89
|
if(isAiAutoMail($data['from'],$data['subject'],$body)===0){
|
91
|
if(isAiAutoMail($data['from'],$data['subject'],$body)===0){
|
|
|
92
|
+ // 检查是否是垃圾箱
|
|
|
93
|
+ $folder = $this->db->cache(3600)->value(folderSql::first($data['folder_id']));
|
|
|
94
|
+ if($folder['folder'] == '垃圾箱'){
|
|
|
95
|
+ $email = $this->db->throw()->cache(3600)->first(\Model\emailSql::first($data['email_id']));
|
|
|
96
|
+ $email['password'] = base64_decode($email['password']);
|
|
|
97
|
+ $email['host'] = $email['imap'];
|
|
|
98
|
+ $mailInstance = \Lib\Imap\ImapPool::get((new \Lib\Imap\ImapConfig($email)));
|
|
|
99
|
+ $msg = $mailInstance->folder($folder['origin_folder'])->msg()->uid($data['uid']);
|
|
|
100
|
+ if(!$msg->move('INBOX')){
|
|
|
101
|
+ if(!$msg->copy('INBOX')){
|
|
|
102
|
+ @file_put_contents(__DIR__."/move_log.log",'移动邮件失败'.json_encode($data,JSON_UNESCAPED_UNICODE)."\n",FILE_APPEND);
|
|
|
103
|
+ }
|
|
|
104
|
+ }
|
|
|
105
|
+ $mailInstance = null;
|
|
|
106
|
+ continue;
|
|
|
107
|
+ }
|
|
|
108
|
+
|
90
|
// 在检查下是否是 收件箱
|
109
|
// 在检查下是否是 收件箱
|
91
|
if($this->db->value(\Model\folderSql::has(['id'=>$data['folder_id'],'origin_folder'=>'INBOX']))){
|
110
|
if($this->db->value(\Model\folderSql::has(['id'=>$data['folder_id'],'origin_folder'=>'INBOX']))){
|
92
|
_echo('处理 '.$data['id']);
|
111
|
_echo('处理 '.$data['id']);
|
93
|
// 检查 是否开启了自动回复
|
112
|
// 检查 是否开启了自动回复
|
94
|
list($postid,$source) = $this->getPostid($data['email_id']);
|
113
|
list($postid,$source) = $this->getPostid($data['email_id']);
|
95
|
if($source == 2){
|
114
|
if($source == 2){
|
96
|
- $email = $this->db->throw()->first(\Model\emailSql::first($data['email_id']));
|
115
|
+ $email = $this->db->throw()->cache(3600)->first(\Model\emailSql::first($data['email_id']));
|
97
|
// 配置
|
116
|
// 配置
|
98
|
$replySetting = $this->getAutoReplySetting($postid,$email['email']);
|
117
|
$replySetting = $this->getAutoReplySetting($postid,$email['email']);
|
99
|
if($replySetting){
|
118
|
if($replySetting){
|