...
|
...
|
@@ -201,7 +201,7 @@ class SyncMail { |
|
|
*/
|
|
|
public function mail(string|\Lib\Imap\Request\Folder $folder, array $uids = [],$isBody = false){
|
|
|
if(is_string($folder)){
|
|
|
$folder = $this->imap->folder($folder);
|
|
|
$folder = $this->imap->folder($folder)->exec();
|
|
|
}
|
|
|
|
|
|
$folder_id = $this->db->value(folderSql::first([
|
...
|
...
|
@@ -298,25 +298,54 @@ class SyncMail { |
|
|
// 是否同步body内容
|
|
|
if($isBody){
|
|
|
|
|
|
// $body = [
|
|
|
// 'lists_id' => $id,
|
|
|
// 'text_html' => []
|
|
|
// ];
|
|
|
//
|
|
|
// foreach ($item->getBody()->getItems() as $item){
|
|
|
// $body['text_html'][] = [
|
|
|
// 'body' => $item->body,
|
|
|
// 'content-type' => $item->get('content-type'),
|
|
|
// 'content-id' => $item->get('content-id'),
|
|
|
// 'charset' => $item->get('charset')
|
|
|
// ];
|
|
|
// }
|
|
|
//
|
|
|
// if($this->db->count(bodySql::has($id))){
|
|
|
// $this->db->update(bodySql::$table,$body,'`lists_id` = '.$id,false);
|
|
|
// }else{
|
|
|
// $this->db->insert(bodySql::$table,$body,false);
|
|
|
// }
|
|
|
$body = [
|
|
|
'lists_id' => $id,
|
|
|
'text_html' => []
|
|
|
];
|
|
|
|
|
|
|
|
|
$body['text_html'][] = [
|
|
|
'body' => base64_encode($item->getBody()->getHtml() ? : $item->getBody()->getText()),
|
|
|
'type' => 'text/html',
|
|
|
'charset' => 'utf-8',
|
|
|
'encode' => 'base64',
|
|
|
];
|
|
|
|
|
|
// 处理附件
|
|
|
foreach ($item->getBody()->getAttachment() as $itemBody){
|
|
|
$tmp = [
|
|
|
'body' => '',
|
|
|
'type' => $itemBody->getFileType(),
|
|
|
'charset' => 'binary',
|
|
|
'encode' => $itemBody->data->get('content-transfer-encoding'),
|
|
|
'name' => $itemBody->getFilename(),
|
|
|
'filename' => $itemBody->getFilename(),
|
|
|
'path' => $itemBody->save(MAIL_ATTACHMENT_PATH)
|
|
|
];
|
|
|
if(!$tmp){
|
|
|
throw new \Exception('请检查附件是否有写入权限');
|
|
|
}
|
|
|
if($itemBody->getContentId()){
|
|
|
$tmp['content-id'] = $itemBody->getContentId();
|
|
|
}
|
|
|
if($itemBody->data->get('Content-Disposition')){
|
|
|
$tmp['content-disposition'] = $itemBody->data->get('Content-Disposition');
|
|
|
}
|
|
|
$tmp['signName'] = explode('/',$tmp['path']);
|
|
|
$tmp['signName'] = end($tmp['signName']);
|
|
|
|
|
|
$body['text_html'][] = $tmp;
|
|
|
|
|
|
}
|
|
|
|
|
|
if($this->db->count(bodySql::has($id))){
|
|
|
$this->db->update(bodySql::$table,$body,'`lists_id` = '.$id,false);
|
|
|
}else{
|
|
|
$this->db->insert(bodySql::$table,$body,false);
|
|
|
}
|
|
|
|
|
|
// 更新描述
|
|
|
$this->db->update(listsSql::$table,['description'=>mb_substr($item->getBody()->getText(),0,150)],dbWhere(['id'=> $id]));
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
|