作者 邓超

x

@@ -139,7 +139,7 @@ function sync_body($id){ @@ -139,7 +139,7 @@ function sync_body($id){
139 $mailServer = new Lib\Mail\Mail($email['email'],base64_decode($email['password']),$email['imap']); 139 $mailServer = new Lib\Mail\Mail($email['email'],base64_decode($email['password']),$email['imap']);
140 140
141 // 登录服务器 141 // 登录服务器
142 - if(!$mailServer->login()){ 142 + if($mailServer->login()!=1){
143 return 2; 143 return 2;
144 } 144 }
145 // $mailServer->client->debug(true,LOG_PATH.'/'.$id['email_id'].'body/'); 145 // $mailServer->client->debug(true,LOG_PATH.'/'.$id['email_id'].'body/');
@@ -151,7 +151,7 @@ class Folder extends Base { @@ -151,7 +151,7 @@ class Folder extends Base {
151 $email['imap'] 151 $email['imap']
152 ); 152 );
153 153
154 - if(!$mail->login()){ 154 + if($mail->login()!=1){
155 app()->e('login_error_imap'); 155 app()->e('login_error_imap');
156 } 156 }
157 157
@@ -250,7 +250,7 @@ class Folder extends Base { @@ -250,7 +250,7 @@ class Folder extends Base {
250 $email['imap'] 250 $email['imap']
251 ); 251 );
252 252
253 - if(!$mail->login()){ 253 + if($mail->login()!=1){
254 app()->e('login_error_imap'); 254 app()->e('login_error_imap');
255 } 255 }
256 256
@@ -537,7 +537,7 @@ class Home extends Base { @@ -537,7 +537,7 @@ class Home extends Base {
537 // 开始远程 537 // 开始远程
538 $mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']); 538 $mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
539 539
540 - if($mailInstance->login()){ 540 + if($mailInstance->login()==1){
541 $ret = $call($mailInstance,array_column($uid,'uid'),$folder['origin_folder'],$to_origin_folder['origin_folder']); 541 $ret = $call($mailInstance,array_column($uid,'uid'),$folder['origin_folder'],$to_origin_folder['origin_folder']);
542 // TODO:: 这个过程无法保证原子性。没办法 542 // TODO:: 这个过程无法保证原子性。没办法
543 // 先复制 543 // 先复制
@@ -590,8 +590,8 @@ class Home extends Base { @@ -590,8 +590,8 @@ class Home extends Base {
590 public function expunge(){ 590 public function expunge(){
591 $email = $this->getEmail(); 591 $email = $this->getEmail();
592 $mailInstance = new Mail($email['email'],base64_decode($email['password']),$email['imap']); 592 $mailInstance = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
593 - $mailInstance->login();  
594 - if($mailInstance->expunge()){ 593 +
  594 + if($mailInstance->login()==1 && $mailInstance->expunge()){
595 app()->_json([]); 595 app()->_json([]);
596 } 596 }
597 597
@@ -668,7 +668,7 @@ class Home extends Base { @@ -668,7 +668,7 @@ class Home extends Base {
668 // 开始远程 668 // 开始远程
669 $mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']); 669 $mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
670 670
671 - if($mailInstance->login()){ 671 + if($mailInstance->login()==1){
672 switch ($d){ 672 switch ($d){
673 // 已读 未读 673 // 已读 未读
674 case 'seen':{ 674 case 'seen':{
@@ -739,7 +739,7 @@ class Home extends Base { @@ -739,7 +739,7 @@ class Home extends Base {
739 db()->delete(bodySql::$table,['lists_id'=>$id]); 739 db()->delete(bodySql::$table,['lists_id'=>$id]);
740 //同步基础信息 740 //同步基础信息
741 $mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']); 741 $mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
742 - if($mail->login()){ 742 + if($mail->login()==1){
743 $folder = db()->value(folderSql::first(['id'=>$data['folder_id']],'origin_folder')); 743 $folder = db()->value(folderSql::first(['id'=>$data['folder_id']],'origin_folder'));
744 if($folder){ 744 if($folder){
745 $mail->client->selectFolder($folder); 745 $mail->client->selectFolder($folder);
@@ -818,7 +818,7 @@ class Home extends Base { @@ -818,7 +818,7 @@ class Home extends Base {
818 if($data['uid']&&$sync_num < 1){ 818 if($data['uid']&&$sync_num < 1){
819 $mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']); 819 $mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
820 820
821 - if($mail->login()){ 821 + if($mail->login()==1){
822 822
823 $folder = db()->value(folderSql::first(['id'=>$data['folder_id']],'origin_folder')); 823 $folder = db()->value(folderSql::first(['id'=>$data['folder_id']],'origin_folder'));
824 if($folder){ 824 if($folder){
@@ -110,7 +110,7 @@ class Home extends Base { @@ -110,7 +110,7 @@ class Home extends Base {
110 $email = $this->getEmail(); 110 $email = $this->getEmail();
111 $udate = app()->request('udate',0,'intval'); 111 $udate = app()->request('udate',0,'intval');
112 if(!$udate){ 112 if(!$udate){
113 - return ''; 113 + return 'no udate';
114 } 114 }
115 // 读取文件夹 115 // 读取文件夹
116 $fids = $this->getFolderIds($email['id']); 116 $fids = $this->getFolderIds($email['id']);
@@ -119,7 +119,9 @@ class Home extends Base { @@ -119,7 +119,9 @@ class Home extends Base {
119 // 实例一个邮箱对象 119 // 实例一个邮箱对象
120 $mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']); 120 $mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
121 // 登录 121 // 登录
122 - $mail->login(); 122 + if($mail->login()!=1){
  123 + return '登录失败';
  124 + }
123 125
124 if(!$folders){ 126 if(!$folders){
125 $mail->syncFolder($email['id']); 127 $mail->syncFolder($email['id']);
@@ -408,6 +408,19 @@ class Imap { @@ -408,6 +408,19 @@ class Imap {
408 return $result[0] == 'ok'; 408 return $result[0] == 'ok';
409 } 409 }
410 410
  411 +
  412 + /**
  413 + * 订阅文件夹
  414 + * @param string $folder
  415 + * @throws \Exception
  416 + * @author:dc
  417 + * @time 2024/6/14 9:30
  418 + */
  419 + public function subscribe(string $folder){
  420 + $result = $this->request("SUBSCRIBE \"{$folder}\"");
  421 +
  422 + }
  423 +
411 /** 424 /**
412 * 获取邮箱所有文件夹 425 * 获取邮箱所有文件夹
413 * @return array 426 * @return array