|
|
<?php
|
|
|
|
|
|
|
|
|
use Model\folderSql;
|
|
|
|
|
|
require_once "../vendor/autoload.php";
|
|
|
|
|
|
|
...
|
...
|
@@ -81,19 +83,36 @@ class fob_ai_mail_auto_reply { |
|
|
continue;
|
|
|
}
|
|
|
// 查询数据
|
|
|
$data = $this->db->throw()->first(\Model\listsSql::first('`id` = '.$did,'`id`,`folder_id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`to`'));
|
|
|
$data = $this->db->throw()->first(\Model\listsSql::first('`id` = '.$did,'`id`,`folder_id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`to`,`uid`'));
|
|
|
if($data && !$data['is_hots']){
|
|
|
|
|
|
// 不是屏蔽的
|
|
|
$body = getBodyHtml(getMailBody($data['id']));
|
|
|
if(isAiAutoMail($data['from'],$data['subject'],$body)===0){
|
|
|
// 检查是否是垃圾箱
|
|
|
$folder = $this->db->cache(3600)->value(folderSql::first($data['folder_id']));
|
|
|
if($folder['folder'] == '垃圾箱'){
|
|
|
$email = $this->db->throw()->cache(3600)->first(\Model\emailSql::first($data['email_id']));
|
|
|
$email['password'] = base64_decode($email['password']);
|
|
|
$email['host'] = $email['imap'];
|
|
|
$mailInstance = \Lib\Imap\ImapPool::get((new \Lib\Imap\ImapConfig($email)));
|
|
|
$msg = $mailInstance->folder($folder['origin_folder'])->msg()->uid($data['uid']);
|
|
|
if(!$msg->move('INBOX')){
|
|
|
if(!$msg->copy('INBOX')){
|
|
|
@file_put_contents(__DIR__."/move_log.log",'移动邮件失败'.json_encode($data,JSON_UNESCAPED_UNICODE)."\n",FILE_APPEND);
|
|
|
}
|
|
|
}
|
|
|
$mailInstance = null;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 在检查下是否是 收件箱
|
|
|
if($this->db->value(\Model\folderSql::has(['id'=>$data['folder_id'],'origin_folder'=>'INBOX']))){
|
|
|
_echo('处理 '.$data['id']);
|
|
|
// 检查 是否开启了自动回复
|
|
|
list($postid,$source) = $this->getPostid($data['email_id']);
|
|
|
if($source == 2){
|
|
|
$email = $this->db->throw()->first(\Model\emailSql::first($data['email_id']));
|
|
|
$email = $this->db->throw()->cache(3600)->first(\Model\emailSql::first($data['email_id']));
|
|
|
// 配置
|
|
|
$replySetting = $this->getAutoReplySetting($postid,$email['email']);
|
|
|
if($replySetting){
|
...
|
...
|
|