|
@@ -7,6 +7,7 @@ use Lib\Imap\Fun; |
|
@@ -7,6 +7,7 @@ use Lib\Imap\Fun; |
7
|
use Lib\Imap\Imap;
|
7
|
use Lib\Imap\Imap;
|
8
|
use Lib\Imap\ImapConfig;
|
8
|
use Lib\Imap\ImapConfig;
|
9
|
use Lib\Imap\ImapPool;
|
9
|
use Lib\Imap\ImapPool;
|
|
|
10
|
+use Lib\Imap\ImapSearch;
|
10
|
use Lib\Imap\Parse\Folder\Folder;
|
11
|
use Lib\Imap\Parse\Folder\Folder;
|
11
|
use Lib\Imap\Parse\MessageItem;
|
12
|
use Lib\Imap\Parse\MessageItem;
|
12
|
use Model\bodySql;
|
13
|
use Model\bodySql;
|
|
@@ -42,6 +43,11 @@ class SyncMail { |
|
@@ -42,6 +43,11 @@ class SyncMail { |
42
|
protected $isStop = false;
|
43
|
protected $isStop = false;
|
43
|
|
44
|
|
44
|
/**
|
45
|
/**
|
|
|
46
|
+ * @var 搜索规则
|
|
|
47
|
+ */
|
|
|
48
|
+ protected $search = null;
|
|
|
49
|
+
|
|
|
50
|
+ /**
|
45
|
* SyncMail constructor.
|
51
|
* SyncMail constructor.
|
46
|
* @param int|string|array $email
|
52
|
* @param int|string|array $email
|
47
|
* @throws \Exception
|
53
|
* @throws \Exception
|
|
@@ -78,6 +84,18 @@ class SyncMail { |
|
@@ -78,6 +84,18 @@ class SyncMail { |
78
|
$this->isStop = true;
|
84
|
$this->isStop = true;
|
79
|
}
|
85
|
}
|
80
|
|
86
|
|
|
|
87
|
+ /**
|
|
|
88
|
+ * 搜索
|
|
|
89
|
+ * @param ImapSearch $search
|
|
|
90
|
+ * @return $this
|
|
|
91
|
+ * @author:dc
|
|
|
92
|
+ * @time 2024/11/11 17:29
|
|
|
93
|
+ */
|
|
|
94
|
+ public function search(ImapSearch $search){
|
|
|
95
|
+ $this->search = $search;
|
|
|
96
|
+ return $this;
|
|
|
97
|
+ }
|
|
|
98
|
+
|
81
|
|
99
|
|
82
|
protected function emailId(){
|
100
|
protected function emailId(){
|
83
|
return $this->email['id'];
|
101
|
return $this->email['id'];
|
|
@@ -175,7 +193,7 @@ class SyncMail { |
|
@@ -175,7 +193,7 @@ class SyncMail { |
175
|
|
193
|
|
176
|
/**
|
194
|
/**
|
177
|
* @param bool $syncMail
|
195
|
* @param bool $syncMail
|
178
|
- * @return bool|void
|
196
|
+ * @return bool|void|array
|
179
|
* @throws \Exception
|
197
|
* @throws \Exception
|
180
|
* @author:dc
|
198
|
* @author:dc
|
181
|
* @time 2024/10/18 17:53
|
199
|
* @time 2024/10/18 17:53
|
|
@@ -198,7 +216,7 @@ class SyncMail { |
|
@@ -198,7 +216,7 @@ class SyncMail { |
198
|
|
216
|
|
199
|
|
217
|
|
200
|
/********************* 同步邮件 **********************/
|
218
|
/********************* 同步邮件 **********************/
|
201
|
-
|
219
|
+ $syncNum = [];
|
202
|
// 循环文件夹
|
220
|
// 循环文件夹
|
203
|
foreach ($folders->all() as $f){
|
221
|
foreach ($folders->all() as $f){
|
204
|
if($this->isStop) return;
|
222
|
if($this->isStop) return;
|
|
@@ -210,6 +228,7 @@ class SyncMail { |
|
@@ -210,6 +228,7 @@ class SyncMail { |
210
|
if ($folder->getTotal()){
|
228
|
if ($folder->getTotal()){
|
211
|
$num = $this->mail($folder);
|
229
|
$num = $this->mail($folder);
|
212
|
if($num){
|
230
|
if($num){
|
|
|
231
|
+ $syncNum[$folder->getName()] = $num;
|
213
|
_echo($this->emailId().' ===> '.$folder->getName().' ===> '.$num);
|
232
|
_echo($this->emailId().' ===> '.$folder->getName().' ===> '.$num);
|
214
|
}
|
233
|
}
|
215
|
}
|
234
|
}
|
|
@@ -239,7 +258,7 @@ class SyncMail { |
|
@@ -239,7 +258,7 @@ class SyncMail { |
239
|
}
|
258
|
}
|
240
|
}
|
259
|
}
|
241
|
|
260
|
|
242
|
-
|
261
|
+ return $syncNum;
|
243
|
}
|
262
|
}
|
244
|
|
263
|
|
245
|
/**
|
264
|
/**
|
|
@@ -275,13 +294,19 @@ class SyncMail { |
|
@@ -275,13 +294,19 @@ class SyncMail { |
275
|
// 选择成功
|
294
|
// 选择成功
|
276
|
if($folder->isOk()){
|
295
|
if($folder->isOk()){
|
277
|
$msg = $folder->msg();
|
296
|
$msg = $folder->msg();
|
|
|
297
|
+
|
|
|
298
|
+ // 是否搜索
|
|
|
299
|
+ if ($this->search instanceof ImapSearch){
|
|
|
300
|
+ $uids = $msg->search($this->search)->getUids();
|
|
|
301
|
+ }
|
|
|
302
|
+
|
278
|
if($uids){
|
303
|
if($uids){
|
279
|
$this->saveMail($folder_id,$msg->uid($uids)->get()->all(),$isBody);
|
304
|
$this->saveMail($folder_id,$msg->uid($uids)->get()->all(),$isBody);
|
280
|
}else{
|
305
|
}else{
|
281
|
$p=1;
|
306
|
$p=1;
|
282
|
while (1){
|
307
|
while (1){
|
283
|
if($this->isStop) return $sync_number;
|
308
|
if($this->isStop) return $sync_number;
|
284
|
- $uids = $msg->forPage($p)->getUids();
|
309
|
+ $uids = $msg->forPage($p)->getOriginUids();
|
285
|
if($uids){
|
310
|
if($uids){
|
286
|
$p++;
|
311
|
$p++;
|
287
|
|
312
|
|