作者 邓超

x

... ... @@ -125,6 +125,28 @@ class Msg extends Request{
return $this;
}
/**
* 只获取uid
* @return array
* @author:dc
* @time 2024/10/12 17:52
*/
public function getUids():array {
$this->folder->exec(); // 防止在其他文件夹下面
$this->cmd(
"%sFETCH %s (UID)",
$this->isUid?'UID ':'',
implode(',',$this->number)
);
$uids = [];
$msg = new Messager($this->result, $this);
foreach ($msg->all() as $item){
$uids[] = $item->uid;
}
return $uids;
}
/**
* 读取邮件列表
... ...
... ... @@ -245,15 +245,27 @@ class SyncMail {
$p=1;
while (1){
if($this->isStop) return;
$uids = $msg->forPage($p)->getUids();
if($uids){
$p++;
$lists = $msg->forPage($p)->get()->all();
// 没有数据就跳出
if(!$lists){
break;
foreach ($uids as $k=>$uid){
if($this->db->cache(86400*30,false)->value(listsSql::first(dbWhere(['email_id'=>$this->emailId(),'folder_id'=>$folder_id,'uid'=>$uid]),'count(*) as c'))){
unset($uids[$k]);
}
}
if(!$uids) continue;
$lists = $msg->uid($uids)->get()->all();
// 没有数据就跳出
if($lists){
$this->saveMail($folder_id,$lists,$isBody);
}
}else{
$p++;
$this->saveMail($folder_id,$lists,$isBody);
break;
}
}
}
... ...