auto_reply_mail.php 2.6 KB
<?php

use Model\listsSql;


/**
 * 自动回复的邮件
 * @author:dc
 * @time 2024/9/6 17:09
 * Class HotMail
 */
class AutoMail {

    public function __construct(){
        $this->db = db();
        $this->start();
    }

    /**
     * @var \Lib\Db|\Lib\DbPool
     */
    private $db;


    /**
     * @author:dc
     * @time 2024/7/18 14:04
     */
    private function start(){

        $filter = isAiAutoMail(true,true);

        $es = es('email_lists_copy');

        $not_must = [];
        foreach ($filter as $f){
            list($t,$str) = $f;
            if($t==2){
                $not_must[] = ["match_phrase"=>["subject"=>$str]];
            }elseif ($t==1){
                $not_must[] = ["match_phrase"=>["from.email"=>$str]];
            }
        }
echo json_encode([
            "_source"  => ["uuid"],
            "query"=>[
                "bool"=>[
                    "must"=>[
                        ["term"=>["folder_as_int" =>  1]], // 收件箱
                        ["term"=>["is_auto" =>  0]], // 非auto
                        ["term"=>["is_hots" =>  0]], // 非预热
                        ["term"=>["deleted" =>  0]], // 非删除
                        // 自动关键字
                        [
                            "bool"  =>  [
                                "should"=> $not_must,
                                "minimum_should_match"  =>  1
                            ]
                        ]
                    ]
                ]
            ]
        ]);exit;
        // 查询自动回的邮件
        $lists = $es->search([
            "_source"  => ["uuid"],
            "query"=>[
                "bool"=>[
                    "must"=>[
                        ["term"=>["folder_as_int" =>  1]], // 收件箱
                        ["term"=>["is_auto" =>  0]], // 非auto
                        ["term"=>["is_hots" =>  0]], // 非预热
                        ["term"=>["deleted" =>  0]], // 非删除
                        // 自动关键字
                        [
                            "bool"  =>  [
                                "should"=> $not_must,
                                "minimum_should_match"  =>  1
                            ]
                        ]
                    ]
                ]
            ]
        ],0,1000,[],1000);

        foreach ($lists['hits']['hits']??[] as $list){
            $id = intval($list['_source']['uuid']??0);
            if($id){
                _echo("id = ".$id);
                redis()->rPush('sync_to_es',$id);
            }
        }

    }

}


include_once "../vendor/autoload.php";


new AutoMail();