...
|
...
|
@@ -61,7 +61,7 @@ class SyncMail { |
|
|
->setHost($email['imap'])
|
|
|
->setEmail($email['email'])
|
|
|
->setPassword(base64_decode($email['password']))
|
|
|
->debug()
|
|
|
// ->debug()
|
|
|
);
|
|
|
|
|
|
$this->login();
|
...
|
...
|
@@ -277,12 +277,17 @@ class SyncMail { |
|
|
|
|
|
|
|
|
if(!$id){
|
|
|
$id = $this->db->insert(listsSql::$table,$data);
|
|
|
|
|
|
$id = $this->insert($data);
|
|
|
if(!$id){
|
|
|
continue;
|
|
|
}
|
|
|
// 新邮件标记
|
|
|
if($item->getFolderName() == 'INBOX')
|
|
|
redis()->incr('have_new_mail_'.$this->emailId(),120);
|
|
|
// 执行事件
|
|
|
$data['Aicc-Hot-Mail'] = $item->header->get('Aicc-Hot-Mail');
|
|
|
|
|
|
Event::call('mail_sync_list',$id, $data);
|
|
|
|
|
|
}else{
|
...
|
...
|
@@ -295,9 +300,18 @@ class SyncMail { |
|
|
|
|
|
$body = [
|
|
|
'lists_id' => $id,
|
|
|
'text_html' => $item->getBody()->getItems()
|
|
|
'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{
|
...
|
...
|
@@ -312,7 +326,38 @@ class SyncMail { |
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询数据 并重试
|
|
|
* @param array $data
|
|
|
* @param int $num
|
|
|
* @return int
|
|
|
* @author:dc
|
|
|
* @time 2024/10/12 15:32
|
|
|
*/
|
|
|
protected function insert(array $data, int $num = 0){
|
|
|
if($num>2){
|
|
|
return 0;
|
|
|
}
|
|
|
try {
|
|
|
$id = $this->db->throw()->insert(listsSql::$table,$data);
|
|
|
}catch (\Throwable $e){
|
|
|
// 字符串编码异常
|
|
|
if(stripos($e->getMessage(),'SQLSTATE[HY000]: General error: 1366 Incorrect string value:')!==false){
|
|
|
// 编码异常的 字段
|
|
|
preg_match("/for column '([a-z0-9_]{2,})' at/",$e->getMessage(),$filed);
|
|
|
if(!empty($filed[1]) && isset($data[$filed[1]])){
|
|
|
// 进行编码转换 大概率会失败
|
|
|
$data[$filed[1]] = mb_convert_encoding($data[$filed[1]],'UTF-8');
|
|
|
}
|
|
|
|
|
|
$id = $this->insert($data,$num+1);
|
|
|
|
|
|
}
|
|
|
logs($e->getMessage());
|
|
|
}
|
|
|
|
|
|
return $id;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|