...
|
...
|
@@ -116,29 +116,32 @@ class fob_hot_ai_mail_auto_reply { |
|
|
if($this->db->cache(3600)->value(\Model\folderSql::has(['id'=>$data['folder_id'],'origin_folder'=>'INBOX']))){
|
|
|
_echo('处理 '.$data['id']);
|
|
|
$email = $this->db->throw()->cache(3600)->first(\Model\emailSql::first($data['email_id']));
|
|
|
// 标记已读
|
|
|
$mailInstance = \Lib\Imap\ImapPool::get((new \Lib\Imap\ImapConfig($email)));
|
|
|
if($mailInstance->login()){
|
|
|
$mailInstance->folder('INBOX')->msg()->uid($data['uid'])->seen();
|
|
|
$mailInstance = null;
|
|
|
}
|
|
|
|
|
|
// 来回超过5次就不回了
|
|
|
if(substr_count($data['subject'],"Re:") < 3){
|
|
|
// 验证是否是ai邮箱
|
|
|
if($this->db->count(sprintf("select count(*) from `hot_mail` where `email` = '%s'",$email['email']))){
|
|
|
// 标记已读
|
|
|
$mailInstance = \Lib\Imap\ImapPool::get((new \Lib\Imap\ImapConfig($email)));
|
|
|
if($mailInstance->login()){
|
|
|
$mailInstance->folder('INBOX')->msg()->uid($data['uid'])->seen();
|
|
|
$mailInstance = null;
|
|
|
}
|
|
|
|
|
|
// 来回超过5次就不回了
|
|
|
if(substr_count($data['subject'],"Re:") < 3){
|
|
|
// 有配置才回复
|
|
|
$ret = \Lib\Mail\MailFun::sendEmail([
|
|
|
'subject' => 'Re:'.$data['subject'],
|
|
|
'tos' => [['email'=>$data['from'],'name'=>explode('@',$data['from'])[0]]],
|
|
|
'body' => $this->trimBody($data,$data['subject']),
|
|
|
'mail-header' => [
|
|
|
'Aicc-Hot-Mail' => 'hot' // 预热邮件
|
|
|
]
|
|
|
],$email);
|
|
|
_echo('回复成功'.$data['id']." ".$email['email'].' to '.$data['from']." ".$ret[1]);
|
|
|
}else{
|
|
|
_echo('来回超过5次就不回了 '.$data['id']);
|
|
|
$ret = \Lib\Mail\MailFun::sendEmail([
|
|
|
'subject' => 'Re:'.$data['subject'],
|
|
|
'tos' => [['email'=>$data['from'],'name'=>explode('@',$data['from'])[0]]],
|
|
|
'body' => $this->trimBody($data,$data['subject']),
|
|
|
'mail-header' => [
|
|
|
'Aicc-Hot-Mail' => 'hot' // 预热邮件
|
|
|
]
|
|
|
],$email);
|
|
|
_echo('回复成功'.$data['id']." ".$email['email'].' to '.$data['from']." ".$ret[1]);
|
|
|
}else{
|
|
|
_echo('来回超过5次就不回了 '.$data['id']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
|