...
|
...
|
@@ -7,6 +7,7 @@ use Lib\Imap\Fun; |
|
|
use Lib\Imap\Imap;
|
|
|
use Lib\Imap\ImapConfig;
|
|
|
use Lib\Imap\ImapPool;
|
|
|
use Lib\Imap\ImapSearch;
|
|
|
use Lib\Imap\Parse\Folder\Folder;
|
|
|
use Lib\Imap\Parse\MessageItem;
|
|
|
use Model\bodySql;
|
...
|
...
|
@@ -42,6 +43,11 @@ class SyncMail { |
|
|
protected $isStop = false;
|
|
|
|
|
|
/**
|
|
|
* @var 搜索规则
|
|
|
*/
|
|
|
protected $search = null;
|
|
|
|
|
|
/**
|
|
|
* SyncMail constructor.
|
|
|
* @param int|string|array $email
|
|
|
* @throws \Exception
|
...
|
...
|
@@ -78,6 +84,18 @@ class SyncMail { |
|
|
$this->isStop = true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 搜索
|
|
|
* @param ImapSearch $search
|
|
|
* @return $this
|
|
|
* @author:dc
|
|
|
* @time 2024/11/11 17:29
|
|
|
*/
|
|
|
public function search(ImapSearch $search){
|
|
|
$this->search = $search;
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
|
|
|
protected function emailId(){
|
|
|
return $this->email['id'];
|
...
|
...
|
@@ -175,7 +193,7 @@ class SyncMail { |
|
|
|
|
|
/**
|
|
|
* @param bool $syncMail
|
|
|
* @return bool|void
|
|
|
* @return bool|void|array
|
|
|
* @throws \Exception
|
|
|
* @author:dc
|
|
|
* @time 2024/10/18 17:53
|
...
|
...
|
@@ -198,7 +216,7 @@ class SyncMail { |
|
|
|
|
|
|
|
|
/********************* 同步邮件 **********************/
|
|
|
|
|
|
$syncNum = [];
|
|
|
// 循环文件夹
|
|
|
foreach ($folders->all() as $f){
|
|
|
if($this->isStop) return;
|
...
|
...
|
@@ -210,6 +228,7 @@ class SyncMail { |
|
|
if ($folder->getTotal()){
|
|
|
$num = $this->mail($folder);
|
|
|
if($num){
|
|
|
$syncNum[$folder->getName()] = $num;
|
|
|
_echo($this->emailId().' ===> '.$folder->getName().' ===> '.$num);
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -239,7 +258,7 @@ class SyncMail { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
return $syncNum;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -275,13 +294,19 @@ class SyncMail { |
|
|
// 选择成功
|
|
|
if($folder->isOk()){
|
|
|
$msg = $folder->msg();
|
|
|
|
|
|
// 是否搜索
|
|
|
if ($this->search instanceof ImapSearch){
|
|
|
$uids = $msg->search($this->search)->getUids();
|
|
|
}
|
|
|
|
|
|
if($uids){
|
|
|
$this->saveMail($folder_id,$msg->uid($uids)->get()->all(),$isBody);
|
|
|
}else{
|
|
|
$p=1;
|
|
|
while (1){
|
|
|
if($this->isStop) return $sync_number;
|
|
|
$uids = $msg->forPage($p)->getUids();
|
|
|
$uids = $msg->forPage($p)->getOriginUids();
|
|
|
if($uids){
|
|
|
$p++;
|
|
|
|
...
|
...
|
|