| ... | ... | @@ -44,7 +44,7 @@ class SyncMail { | 
|  |  | * @param int|string|array $email | 
|  |  | * @throws \Exception | 
|  |  | */ | 
|  |  | public function __construct(int|string|array $email) | 
|  |  | public function __construct(int|string|array $email,\Lib\Imap\Imap|null $imap = null) | 
|  |  | { | 
|  |  | $this->db = db(); | 
|  |  |  | 
| ... | ... | @@ -56,16 +56,20 @@ class SyncMail { | 
|  |  | } | 
|  |  | $this->email = $email; | 
|  |  | // 实例一个imap类 | 
|  |  | $this->imap = ImapPool::get( | 
|  |  | (new ImapConfig()) | 
|  |  | ->setHost($email['imap']) | 
|  |  | ->setEmail($email['email']) | 
|  |  | ->setPassword(base64_decode($email['password'])) | 
|  |  | if($imap instanceof \Lib\Imap\Imap){ | 
|  |  | $this->imap = $imap; | 
|  |  | }else{ | 
|  |  | $this->imap = ImapPool::get( | 
|  |  | (new ImapConfig()) | 
|  |  | ->setHost($email['imap']) | 
|  |  | ->setEmail($email['email']) | 
|  |  | ->setPassword(base64_decode($email['password'])) | 
|  |  | //                ->debug() | 
|  |  | ); | 
|  |  | ); | 
|  |  |  | 
|  |  | $this->login(); | 
|  |  | $this->login(); | 
|  |  |  | 
|  |  | } | 
|  |  | } | 
|  |  |  | 
|  |  | public function stop(){ | 
| ... | ... | @@ -146,12 +150,13 @@ class SyncMail { | 
|  |  | } | 
|  |  |  | 
|  |  | /** | 
|  |  | * 同步 | 
|  |  | * @param bool $syncMail | 
|  |  | * @return bool|void | 
|  |  | * @throws \Exception | 
|  |  | * @author:dc | 
|  |  | * @time 2024/9/26 10:46 | 
|  |  | * @time 2024/10/18 17:53 | 
|  |  | */ | 
|  |  | public function sync(){ | 
|  |  | public function sync($syncMail = true){ | 
|  |  | $this->isStop = false; | 
|  |  | /*********************************** 同步文件夹 ***************************************/ | 
|  |  | // 获取文件夹 | 
| ... | ... | @@ -161,6 +166,9 @@ class SyncMail { | 
|  |  | // 删除以前的 | 
|  |  | $this->db->delete(folderSql::$table,['uuid.notin'=>$uuids,'email_id'=>$this->emailId()]); | 
|  |  | } | 
|  |  |  | 
|  |  | if (!$syncMail) return true; | 
|  |  |  | 
|  |  | _echo($this->emailId().' ===> 文件夹同步成功'); | 
|  |  | if($this->isStop) return; | 
|  |  |  | 
| ... | ... | @@ -313,6 +321,8 @@ class SyncMail { | 
|  |  | 'is_file'  =>  $item->isAttachment() ? 1: 0 //是否附件 | 
|  |  | ]; | 
|  |  |  | 
|  |  | $data['from'] = mb_substr($data['from'],0,120); | 
|  |  |  | 
|  |  | // 不知道为什么 有些邮件标题有下划线,但是发件那边并没有添加下划线 | 
|  |  | $data['subject'] = str_replace('_',' ',$data['subject']); | 
|  |  |  | 
... | ... |  |