作者 邓超

检查 邮箱

@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 2
3 namespace Controller; 3 namespace Controller;
4 4
  5 +use Lib\Imap\ImapConfig;
  6 +use Lib\Imap\ImapPool;
5 use Lib\Mail\Mail; 7 use Lib\Mail\Mail;
6 use Lib\Mail\MailFun; 8 use Lib\Mail\MailFun;
7 use Lib\UploadFile; 9 use Lib\UploadFile;
@@ -316,19 +318,27 @@ class Home extends Base { @@ -316,19 +318,27 @@ class Home extends Base {
316 318
317 319
318 $lists = db()->all(emailSql::getValues(['email'=>web_request_emails()],'`id`,`pwd_error`,`email`,`password`,`imap`')); 320 $lists = db()->all(emailSql::getValues(['email'=>web_request_emails()],'`id`,`pwd_error`,`email`,`password`,`imap`'));
  321 + if(count($lists)>1){
319 return array_column($lists,'pwd_error','email'); 322 return array_column($lists,'pwd_error','email');
  323 + }
320 324
321 foreach ($lists as $k=>$list){ 325 foreach ($lists as $k=>$list){
322 if(!$list['pwd_error']){ 326 if(!$list['pwd_error']){
323 - $mail = new \Lib\Mail\Mail($list['email'],base64_decode($list['password']),$list['imap']);  
324 -  
325 - // 2次登录请求  
326 - if($mail->login()!==1){  
327 - if($mail->login()!==1){  
328 - $lists[$k]['pwd_error'] = 1; 327 + $list['host'] = $list['imap'];
  328 + $list['password'] = base64_decode($list['password']);
  329 + $imap = ImapPool::get(new ImapConfig($list));
  330 + $n = $imap->login()->isOk();
  331 + if($n){
  332 + if($lists[$k]['pwd_error']){
  333 + db()->update(emailSql::$table,['pwd_error'=>0],'`id` = '.$list['id']);
  334 + }
  335 + $lists[$k]['pwd_error'] = 0;
  336 + }else{
  337 + if(!$lists[$k]['pwd_error']){
  338 + db()->update(emailSql::$table,['pwd_error'=>1],'`id` = '.$list['id']);
329 } 339 }
  340 + $lists[$k]['pwd_error'] = 1;
330 } 341 }
331 - $mail = null;  
332 } 342 }
333 343
334 } 344 }