作者 邓超

超迹配置的自动回复

@@ -138,14 +138,27 @@ class fob_ai_mail_auto_reply { @@ -138,14 +138,27 @@ class fob_ai_mail_auto_reply {
138 // 配置 138 // 配置
139 $replySetting = $this->getAutoReplySetting($postid,$email['email']); 139 $replySetting = $this->getAutoReplySetting($postid,$email['email']);
140 if($replySetting){ 140 if($replySetting){
141 - // 有配置才回复  
142 - $ret = \Lib\Mail\MailFun::sendEmail([  
143 - 'subject' => 'Re:'.$data['subject'],  
144 - 'tos' => [['email'=>$data['from'],'name'=>explode('@',$data['from'])[0]]],  
145 - 'body' => $this->trimBody($data,$replySetting['content'],$body)  
146 - ],$email);  
147 - _echo('回复成功'.$data['id'].'==='.$postid);  
148 - $this->log([$data,$replySetting,$ret]); // 立即写入日志 141 + $isnext = true;
  142 + if($replySetting['reply_num']??0){
  143 + $nk = 'fobaimailautoreplynum:'.$postid.':'.md5($data['from']);
  144 + if(redis()->get($nk,0) > $replySetting['reply_num']){
  145 + $isnext = false;
  146 + }else{
  147 + redis()->incr($nk);
  148 + }
  149 + }
  150 +
  151 + if($isnext){
  152 + // 有配置才回复
  153 + $ret = \Lib\Mail\MailFun::sendEmail([
  154 + 'subject' => 'Re:'.$data['subject'],
  155 + 'tos' => [['email'=>$data['from'],'name'=>explode('@',$data['from'])[0]]],
  156 + 'body' => $this->trimBody($data,$replySetting['content'],$body)
  157 + ],$email);
  158 + _echo('回复成功'.$data['id'].'==='.$postid);
  159 + $this->log([$data,$replySetting,$ret]); // 立即写入日志
  160 + }
  161 +
149 }else{ 162 }else{
150 _echo('没有找到配置'.$data['id'].'==='.$postid); 163 _echo('没有找到配置'.$data['id'].'==='.$postid);
151 } 164 }