作者 邓超

1

... ... @@ -5,6 +5,7 @@ namespace Controller;
use Lib\Mail\Mail;
use Lib\Mail\MailFun;
use Lib\Verify;
use Model\bodySql;
use Model\emailSql;
use Model\folderSql;
use Model\listsSql;
... ... @@ -358,6 +359,53 @@ class Home extends Base {
}
/**
* @author:dc
* @time 2023/4/1 9:24
*/
public function info(){
$id = app()->request('id',0,'intval');
// 没有,说明没有同步过来
$email = $this->getEmail();
$data = db()->first(listsSql::first(dbWhere(['id'=>$id,'email_id'=>$email['id']])));
if($data){
$sync_num = 0;
HOME_INFO_BODY:
// 循环几次
if($sync_num < 1){
$body = db()->first(bodySql::first($id));
if($body){
return [
'data' => [
'info' => $data,
'body' => json_decode($body['text_html'],true)
]
];
}
$mail = new Mail($email['email'],base64_decode($email['passwird']),$email['imap']);
if($mail->login()){
$folder = db()->value(folderSql::first(dbWhere(['id'=>$data['folder_id']]),'origin_folder'));
if($folder){
$ret = $mail->syncBody($folder,$data['uid'],$id);
$sync_num++;
if($ret === true){
goto HOME_INFO_BODY;
}
}
}
}
}
app()->e('mail_body_error');
}
}
... ...
... ... @@ -319,6 +319,16 @@ function folderAlias($folder){
'Drafts' => '草稿箱',
'Junk' => '垃圾箱',
'Deleted Messages' => '回收站',
'垃圾邮件' => '垃圾箱',
'已删除' => '回收站',
'已发送' => '发件箱',
'垃圾桶' => '垃圾箱',
'垃圾郵件' => '垃圾箱',
'寄件備份' => '发件箱',
'草稿' => '草稿箱',
];
... ...
... ... @@ -67,7 +67,8 @@ return [
'mail_not' => '邮件不存在'
'mail_not' => '邮件不存在',
'mail_body_error' => '邮件内容拉取失败',
... ...
... ... @@ -323,7 +323,7 @@ class Mail {
$description = '';
foreach ($body as $key=>$item){
if(!$description && in_array($item['type'],['text/html','text/plain'])){
$description = mb_substr(trim(strip_tags($item['body'])),0,190);
$description = mb_substr(trim(str_replace(["\n",' ',"\\n","&nbsp;"],'',strip_tags($item['body']))),0,190);
}
if(!empty($body[$key]['body'])){
$body[$key]['body'] = base64_encode($body[$key]['body']);
... ...
... ... @@ -17,6 +17,8 @@ return [
'login' => [\Controller\Login::class, 'login'],
// 邮件列表
'lists' => [\Controller\Home::class, 'lists'],
// 邮件详情
'info' => [\Controller\Home::class, 'info'],
// 邮件文件夹
'folder' => [\Controller\Folder::class, 'lists'],
// 创建文件夹
... ...