empty_subject_check.php 1.0 KB
<?php

/**
 * 检查邮件同步时出现的空数据,很奇怪
 * 定时任务,每1小时执行一次
 */

require_once "../vendor/autoload.php";


$id = redis()->get('empty_subject_check',185163874);
while($id){

    $list = db()->first(\Model\listsSql::first('`id` > '.$id.' and `subject` = ""','`id`,`email_id`,`folder_id`,`uid`'));
    if(!$list){
        break;
    }
    $id = $list['id']??0;

    echo $id."\n";

    $email = db()->first(\Model\emailSql::first($list['email_id']));


    $folder = db()->first(\Model\folderSql::first($list['folder_id']));
    if(!$folder){continue;}

    $config = (new \Lib\Imap\ImapConfig())
        // ->debug()
        ->setEmail($email['email'])
        ->setPassword(base64_decode($email['password']))
        ->setHost($email['imap']);

    $imap = \Lib\Imap\ImapPool::get($config);
    //$imap->debug();
    $login = $imap->login();
    if($login->isOk()){
        (new \Service\SyncMail($email,$imap))->mail($folder['origin_folder'],[$list['uid']]);
    }

}

redis()->set('empty_subject_check',$id);

exit;