| 
...
 | 
...
 | 
@@ -104,13 +104,22 @@ class fob_hot_ai_mail_auto_reply { | 
| 
 | 
 | 
                     redis()->rPush('new_hot_mail_auto_reply_ids',$id.'.'.$this->getDelayTime());
 | 
| 
 | 
 | 
                     continue;
 | 
| 
 | 
 | 
                 }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
                 $h = (int) date('H');
 | 
| 
 | 
 | 
                 if($h >= 23 || $h < 6 ){
 | 
| 
 | 
 | 
                     sleep(5);
 | 
| 
 | 
 | 
                     return 0;
 | 
| 
 | 
 | 
                 }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
                  if($time > time()){
 | 
| 
 | 
 | 
                      redis()->rPush('new_hot_mail_auto_reply_ids',$id);
 | 
| 
 | 
 | 
                      usleep(10000);
 | 
| 
 | 
 | 
                      // echo $did." ".date("Y-m-d H:i:s",$time)." 时间未到 \n";
 | 
| 
 | 
 | 
                      continue;
 | 
| 
 | 
 | 
                  }
 | 
| 
 | 
 | 
                 // 查询数据
 | 
| 
 | 
 | 
                 $data = $this->db->first(\Model\listsSql::first('`id` = '.$did,'`id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`uid`'));
 | 
| 
 | 
 | 
                 $data = $this->db->first(\Model\listsSql::first('`id` = '.$did,'`id`,`to`,`folder_id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`uid`'));
 | 
| 
 | 
 | 
                 if($data && $data['is_hots']){
 | 
| 
 | 
 | 
                     // 在检查下是否是 收件箱
 | 
| 
 | 
 | 
                     if($this->db->cache(3600)->value(\Model\folderSql::has(['id'=>$data['folder_id'],'origin_folder'=>'INBOX']))){
 | 
| 
...
 | 
...
 | 
@@ -120,7 +129,9 @@ class fob_hot_ai_mail_auto_reply { | 
| 
 | 
 | 
                         // 验证是否是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)));
 | 
| 
 | 
 | 
                             $email['password'] = base64_decode($email['password']);
 | 
| 
 | 
 | 
                             $email['host'] = $email['imap'];
 | 
| 
 | 
 | 
                             $mailInstance = \Lib\Imap\ImapPool::get(new \Lib\Imap\ImapConfig($email));
 | 
| 
 | 
 | 
                             if($mailInstance->login()){
 | 
| 
 | 
 | 
                                 $mailInstance->folder('INBOX')->msg()->uid($data['uid'])->seen();
 | 
| 
 | 
 | 
                                 $mailInstance = null;
 | 
| 
...
 | 
...
 | 
@@ -129,6 +140,8 @@ class fob_hot_ai_mail_auto_reply { | 
| 
 | 
 | 
                             // 来回超过5次就不回了
 | 
| 
 | 
 | 
                             if(substr_count($data['subject'],"Re:") < 3){
 | 
| 
 | 
 | 
 // 有配置才回复
 | 
| 
 | 
 | 
                                 $email['hot_email'] = 1;
 | 
| 
 | 
 | 
                                 $email['password'] = base64_encode($email['password']);
 | 
| 
 | 
 | 
                                 $ret = \Lib\Mail\MailFun::sendEmail([
 | 
| 
 | 
 | 
                                     'subject'   =>  'Re:'.$data['subject'],
 | 
| 
 | 
 | 
                                     'tos'   =>  [['email'=>$data['from'],'name'=>explode('@',$data['from'])[0]]],
 | 
| 
...
 | 
...
 | 
@@ -137,7 +150,8 @@ class fob_hot_ai_mail_auto_reply { | 
| 
 | 
 | 
                                         'Aicc-Hot-Mail' =>  'hot' // 预热邮件
 | 
| 
 | 
 | 
                                     ]
 | 
| 
 | 
 | 
                                 ],$email);
 | 
| 
 | 
 | 
                                 _echo('回复成功'.$data['id']." ".$email['email'].' to '.$data['from']." ".$ret[1]);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
                                 _echo(($ret[0]?'回复成功 ':'失败 ').$data['id']." ".$email['email'].' to '.$data['from']." ".$ret[1]);
 | 
| 
 | 
 | 
                             }else{
 | 
| 
 | 
 | 
                                 _echo('来回超过5次就不回了 '.$data['id']);
 | 
| 
 | 
 | 
                             }
 | 
| 
...
 | 
...
 | 
@@ -157,9 +171,19 @@ class fob_hot_ai_mail_auto_reply { | 
| 
 | 
 | 
         // 随机body内容
 | 
| 
 | 
 | 
         $reply = $this->bodys[array_rand($this->bodys)];
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         return "<pre>------------------ 原始邮件 ------------------
 | 
| 
 | 
 | 
         if(rand(1,2)==1){
 | 
| 
 | 
 | 
             $reply = "<pre>".$reply."</pre>";
 | 
| 
 | 
 | 
         }else{
 | 
| 
 | 
 | 
             $reply = array_map(function ($v){
 | 
| 
 | 
 | 
                 return "<p>".$v."</p>";
 | 
| 
 | 
 | 
             },explode("\n",$reply));
 | 
| 
 | 
 | 
             $reply = implode("\n",$reply);
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         return "<pre style='background-color: #e8d6d6;'>------------------ 原始邮件 ------------------
 | 
| 
 | 
 | 
 发件人: {$data['from']};
 | 
| 
 | 
 | 
 发送时间: ".date("Y年m月d日 H:i",$data['udate'])."
 | 
| 
 | 
 | 
 发送时间: " .date("Y年m月d日 H:i",$data['udate'])."
 | 
| 
 | 
 | 
 收件人: {$data['to']};
 | 
| 
 | 
 | 
 主题: {$data['subject']}
 | 
| 
 | 
 | 
 
 | 
...
 | 
...
 | 
 |