作者 邓超

预热自动回复

@@ -116,29 +116,32 @@ class fob_hot_ai_mail_auto_reply { @@ -116,29 +116,32 @@ class fob_hot_ai_mail_auto_reply {
116 if($this->db->cache(3600)->value(\Model\folderSql::has(['id'=>$data['folder_id'],'origin_folder'=>'INBOX']))){ 116 if($this->db->cache(3600)->value(\Model\folderSql::has(['id'=>$data['folder_id'],'origin_folder'=>'INBOX']))){
117 _echo('处理 '.$data['id']); 117 _echo('处理 '.$data['id']);
118 $email = $this->db->throw()->cache(3600)->first(\Model\emailSql::first($data['email_id'])); 118 $email = $this->db->throw()->cache(3600)->first(\Model\emailSql::first($data['email_id']));
119 - // 标记已读  
120 - $mailInstance = \Lib\Imap\ImapPool::get((new \Lib\Imap\ImapConfig($email)));  
121 - if($mailInstance->login()){  
122 - $mailInstance->folder('INBOX')->msg()->uid($data['uid'])->seen();  
123 - $mailInstance = null;  
124 - }  
125 119
126 - // 来回超过5次就不回了  
127 - if(substr_count($data['subject'],"Re:") < 3){ 120 + // 验证是否是ai邮箱
  121 + if($this->db->count(sprintf("select count(*) from `hot_mail` where `email` = '%s'",$email['email']))){
  122 + // 标记已读
  123 + $mailInstance = \Lib\Imap\ImapPool::get((new \Lib\Imap\ImapConfig($email)));
  124 + if($mailInstance->login()){
  125 + $mailInstance->folder('INBOX')->msg()->uid($data['uid'])->seen();
  126 + $mailInstance = null;
  127 + }
  128 +
  129 + // 来回超过5次就不回了
  130 + if(substr_count($data['subject'],"Re:") < 3){
128 // 有配置才回复 131 // 有配置才回复
129 - $ret = \Lib\Mail\MailFun::sendEmail([  
130 - 'subject' => 'Re:'.$data['subject'],  
131 - 'tos' => [['email'=>$data['from'],'name'=>explode('@',$data['from'])[0]]],  
132 - 'body' => $this->trimBody($data,$data['subject']),  
133 - 'mail-header' => [  
134 - 'Aicc-Hot-Mail' => 'hot' // 预热邮件  
135 - ]  
136 - ],$email);  
137 - _echo('回复成功'.$data['id']." ".$email['email'].' to '.$data['from']." ".$ret[1]);  
138 - }else{  
139 - _echo('来回超过5次就不回了 '.$data['id']); 132 + $ret = \Lib\Mail\MailFun::sendEmail([
  133 + 'subject' => 'Re:'.$data['subject'],
  134 + 'tos' => [['email'=>$data['from'],'name'=>explode('@',$data['from'])[0]]],
  135 + 'body' => $this->trimBody($data,$data['subject']),
  136 + 'mail-header' => [
  137 + 'Aicc-Hot-Mail' => 'hot' // 预热邮件
  138 + ]
  139 + ],$email);
  140 + _echo('回复成功'.$data['id']." ".$email['email'].' to '.$data['from']." ".$ret[1]);
  141 + }else{
  142 + _echo('来回超过5次就不回了 '.$data['id']);
  143 + }
140 } 144 }
141 -  
142 } 145 }
143 146
144 } 147 }