正在显示
1 个修改的文件
包含
39 行增加
和
8 行删除
| @@ -89,20 +89,30 @@ class fob_ai_mail_auto_reply { | @@ -89,20 +89,30 @@ class fob_ai_mail_auto_reply { | ||
| 89 | // 不是屏蔽的 | 89 | // 不是屏蔽的 | 
| 90 | $body = getBodyHtml(getMailBody($data['id'])); | 90 | $body = getBodyHtml(getMailBody($data['id'])); | 
| 91 | if(isAiAutoMail($data['from'],$data['subject'],$body)===0){ | 91 | if(isAiAutoMail($data['from'],$data['subject'],$body)===0){ | 
| 92 | + | ||
| 93 | + | ||
| 92 | // 检查是否是垃圾箱 | 94 | // 检查是否是垃圾箱 | 
| 93 | $folder = $this->db->cache(3600)->value(folderSql::first($data['folder_id'])); | 95 | $folder = $this->db->cache(3600)->value(folderSql::first($data['folder_id'])); | 
| 94 | if($folder['folder'] == '垃圾箱'){ | 96 | if($folder['folder'] == '垃圾箱'){ | 
| 95 | $email = $this->db->throw()->cache(3600)->first(\Model\emailSql::first($data['email_id'])); | 97 | $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); | 98 | + | 
| 99 | + // 检查 是否开启了自动回复 | ||
| 100 | + list($postid,$source) = $this->getPostid($data['email_id']); | ||
| 101 | + // 配置 | ||
| 102 | + $replySetting = $this->getAutoReplySettingJunk($postid,$email['email']); | ||
| 103 | + if($replySetting){ | ||
| 104 | + $email['password'] = base64_decode($email['password']); | ||
| 105 | + $email['host'] = $email['imap']; | ||
| 106 | + $mailInstance = \Lib\Imap\ImapPool::get((new \Lib\Imap\ImapConfig($email))); | ||
| 107 | + $msg = $mailInstance->folder($folder['origin_folder'])->msg()->uid($data['uid']); | ||
| 108 | + if(!$msg->move('INBOX')){ | ||
| 109 | + if(!$msg->copy('INBOX')){ | ||
| 110 | + @file_put_contents(__DIR__."/move_log.log",'移动邮件失败'.json_encode($data,JSON_UNESCAPED_UNICODE)."\n",FILE_APPEND); | ||
| 111 | + } | ||
| 103 | } | 112 | } | 
| 113 | + $mailInstance = null; | ||
| 104 | } | 114 | } | 
| 105 | - $mailInstance = null; | 115 | + | 
| 106 | continue; | 116 | continue; | 
| 107 | } | 117 | } | 
| 108 | 118 | ||
| @@ -207,6 +217,27 @@ class fob_ai_mail_auto_reply { | @@ -207,6 +217,27 @@ class fob_ai_mail_auto_reply { | ||
| 207 | return false; | 217 | return false; | 
| 208 | } | 218 | } | 
| 209 | 219 | ||
| 220 | + public function getAutoReplySettingJunk($postid,$email){ | ||
| 221 | + $sets = $this->fob_db->throw()->all("select * from `ai_mail_auto_reply_setting` where ".dbWhere([ | ||
| 222 | + 'postid' => $postid | ||
| 223 | + ])); | ||
| 224 | + if(!$sets){ | ||
| 225 | + return false; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + foreach ($sets as $set){ | ||
| 229 | + $set['emails'] = @json_decode($set['emails'],true); | ||
| 230 | + // 是否开启了 | ||
| 231 | + if($set['emails']&&(in_array($email,$set['emails'])||in_array('所有邮箱',$set['emails']))){ | ||
| 232 | + if($set['junk_to_inbox']){ | ||
| 233 | + return true; | ||
| 234 | + } | ||
| 235 | + } | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + return false; | ||
| 239 | + } | ||
| 240 | + | ||
| 210 | 241 | ||
| 211 | /** | 242 | /** | 
| 212 | * 项目id | 243 | * 项目id | 
- 
请 注册 或 登录 后发表评论