|
@@ -44,7 +44,7 @@ class SyncMail { |
|
@@ -44,7 +44,7 @@ class SyncMail { |
44
|
* @param int|string|array $email
|
44
|
* @param int|string|array $email
|
45
|
* @throws \Exception
|
45
|
* @throws \Exception
|
46
|
*/
|
46
|
*/
|
47
|
- public function __construct(int|string|array $email)
|
47
|
+ public function __construct(int|string|array $email,\Lib\Imap\Imap|null $imap = null)
|
48
|
{
|
48
|
{
|
49
|
$this->db = db();
|
49
|
$this->db = db();
|
50
|
|
50
|
|
|
@@ -56,6 +56,9 @@ class SyncMail { |
|
@@ -56,6 +56,9 @@ class SyncMail { |
56
|
}
|
56
|
}
|
57
|
$this->email = $email;
|
57
|
$this->email = $email;
|
58
|
// 实例一个imap类
|
58
|
// 实例一个imap类
|
|
|
59
|
+ if($imap instanceof \Lib\Imap\Imap){
|
|
|
60
|
+ $this->imap = $imap;
|
|
|
61
|
+ }else{
|
59
|
$this->imap = ImapPool::get(
|
62
|
$this->imap = ImapPool::get(
|
60
|
(new ImapConfig())
|
63
|
(new ImapConfig())
|
61
|
->setHost($email['imap'])
|
64
|
->setHost($email['imap'])
|
|
@@ -67,6 +70,7 @@ class SyncMail { |
|
@@ -67,6 +70,7 @@ class SyncMail { |
67
|
$this->login();
|
70
|
$this->login();
|
68
|
|
71
|
|
69
|
}
|
72
|
}
|
|
|
73
|
+ }
|
70
|
|
74
|
|
71
|
public function stop(){
|
75
|
public function stop(){
|
72
|
$this->isStop = true;
|
76
|
$this->isStop = true;
|
|
@@ -146,12 +150,13 @@ class SyncMail { |
|
@@ -146,12 +150,13 @@ class SyncMail { |
146
|
}
|
150
|
}
|
147
|
|
151
|
|
148
|
/**
|
152
|
/**
|
149
|
- * 同步
|
153
|
+ * @param bool $syncMail
|
|
|
154
|
+ * @return bool|void
|
150
|
* @throws \Exception
|
155
|
* @throws \Exception
|
151
|
* @author:dc
|
156
|
* @author:dc
|
152
|
- * @time 2024/9/26 10:46
|
157
|
+ * @time 2024/10/18 17:53
|
153
|
*/
|
158
|
*/
|
154
|
- public function sync(){
|
159
|
+ public function sync($syncMail = true){
|
155
|
$this->isStop = false;
|
160
|
$this->isStop = false;
|
156
|
/*********************************** 同步文件夹 ***************************************/
|
161
|
/*********************************** 同步文件夹 ***************************************/
|
157
|
// 获取文件夹
|
162
|
// 获取文件夹
|
|
@@ -161,6 +166,9 @@ class SyncMail { |
|
@@ -161,6 +166,9 @@ class SyncMail { |
161
|
// 删除以前的
|
166
|
// 删除以前的
|
162
|
$this->db->delete(folderSql::$table,['uuid.notin'=>$uuids,'email_id'=>$this->emailId()]);
|
167
|
$this->db->delete(folderSql::$table,['uuid.notin'=>$uuids,'email_id'=>$this->emailId()]);
|
163
|
}
|
168
|
}
|
|
|
169
|
+
|
|
|
170
|
+ if (!$syncMail) return true;
|
|
|
171
|
+
|
164
|
_echo($this->emailId().' ===> 文件夹同步成功');
|
172
|
_echo($this->emailId().' ===> 文件夹同步成功');
|
165
|
if($this->isStop) return;
|
173
|
if($this->isStop) return;
|
166
|
|
174
|
|
|
@@ -313,6 +321,8 @@ class SyncMail { |
|
@@ -313,6 +321,8 @@ class SyncMail { |
313
|
'is_file' => $item->isAttachment() ? 1: 0 //是否附件
|
321
|
'is_file' => $item->isAttachment() ? 1: 0 //是否附件
|
314
|
];
|
322
|
];
|
315
|
|
323
|
|
|
|
324
|
+ $data['from'] = mb_substr($data['from'],0,120);
|
|
|
325
|
+
|
316
|
// 不知道为什么 有些邮件标题有下划线,但是发件那边并没有添加下划线
|
326
|
// 不知道为什么 有些邮件标题有下划线,但是发件那边并没有添加下划线
|
317
|
$data['subject'] = str_replace('_',' ',$data['subject']);
|
327
|
$data['subject'] = str_replace('_',' ',$data['subject']);
|
318
|
|
328
|
|