作者 邓超

x

... ... @@ -139,7 +139,7 @@ function sync_body($id){
$mailServer = new Lib\Mail\Mail($email['email'],base64_decode($email['password']),$email['imap']);
// 登录服务器
if(!$mailServer->login()){
if($mailServer->login()!=1){
return 2;
}
// $mailServer->client->debug(true,LOG_PATH.'/'.$id['email_id'].'body/');
... ...
... ... @@ -151,7 +151,7 @@ class Folder extends Base {
$email['imap']
);
if(!$mail->login()){
if($mail->login()!=1){
app()->e('login_error_imap');
}
... ... @@ -250,7 +250,7 @@ class Folder extends Base {
$email['imap']
);
if(!$mail->login()){
if($mail->login()!=1){
app()->e('login_error_imap');
}
... ...
... ... @@ -537,7 +537,7 @@ class Home extends Base {
// 开始远程
$mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
if($mailInstance->login()){
if($mailInstance->login()==1){
$ret = $call($mailInstance,array_column($uid,'uid'),$folder['origin_folder'],$to_origin_folder['origin_folder']);
// TODO:: 这个过程无法保证原子性。没办法
// 先复制
... ... @@ -590,8 +590,8 @@ class Home extends Base {
public function expunge(){
$email = $this->getEmail();
$mailInstance = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
$mailInstance->login();
if($mailInstance->expunge()){
if($mailInstance->login()==1 && $mailInstance->expunge()){
app()->_json([]);
}
... ... @@ -668,7 +668,7 @@ class Home extends Base {
// 开始远程
$mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
if($mailInstance->login()){
if($mailInstance->login()==1){
switch ($d){
// 已读 未读
case 'seen':{
... ... @@ -739,7 +739,7 @@ class Home extends Base {
db()->delete(bodySql::$table,['lists_id'=>$id]);
//同步基础信息
$mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
if($mail->login()){
if($mail->login()==1){
$folder = db()->value(folderSql::first(['id'=>$data['folder_id']],'origin_folder'));
if($folder){
$mail->client->selectFolder($folder);
... ... @@ -818,7 +818,7 @@ class Home extends Base {
if($data['uid']&&$sync_num < 1){
$mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
if($mail->login()){
if($mail->login()==1){
$folder = db()->value(folderSql::first(['id'=>$data['folder_id']],'origin_folder'));
if($folder){
... ...
... ... @@ -110,7 +110,7 @@ class Home extends Base {
$email = $this->getEmail();
$udate = app()->request('udate',0,'intval');
if(!$udate){
return '';
return 'no udate';
}
// 读取文件夹
$fids = $this->getFolderIds($email['id']);
... ... @@ -119,7 +119,9 @@ class Home extends Base {
// 实例一个邮箱对象
$mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
// 登录
$mail->login();
if($mail->login()!=1){
return '登录失败';
}
if(!$folders){
$mail->syncFolder($email['id']);
... ...
... ... @@ -408,6 +408,19 @@ class Imap {
return $result[0] == 'ok';
}
/**
* 订阅文件夹
* @param string $folder
* @throws \Exception
* @author:dc
* @time 2024/6/14 9:30
*/
public function subscribe(string $folder){
$result = $this->request("SUBSCRIBE \"{$folder}\"");
}
/**
* 获取邮箱所有文件夹
* @return array
... ...