正在显示
1 个修改的文件
包含
33 行增加
和
9 行删除
@@ -104,13 +104,22 @@ class fob_hot_ai_mail_auto_reply { | @@ -104,13 +104,22 @@ class fob_hot_ai_mail_auto_reply { | ||
104 | redis()->rPush('new_hot_mail_auto_reply_ids',$id.'.'.$this->getDelayTime()); | 104 | redis()->rPush('new_hot_mail_auto_reply_ids',$id.'.'.$this->getDelayTime()); |
105 | continue; | 105 | continue; |
106 | } | 106 | } |
107 | - if($time > time()){ | ||
108 | - redis()->rPush('new_hot_mail_auto_reply_ids',$id); | ||
109 | - usleep(10000); | ||
110 | - continue; | 107 | + |
108 | + $h = (int) date('H'); | ||
109 | + if($h >= 23 || $h < 6 ){ | ||
110 | + sleep(5); | ||
111 | + return 0; | ||
111 | } | 112 | } |
113 | + | ||
114 | + | ||
115 | + if($time > time()){ | ||
116 | + redis()->rPush('new_hot_mail_auto_reply_ids',$id); | ||
117 | + usleep(10000); | ||
118 | + // echo $did." ".date("Y-m-d H:i:s",$time)." 时间未到 \n"; | ||
119 | + continue; | ||
120 | + } | ||
112 | // 查询数据 | 121 | // 查询数据 |
113 | - $data = $this->db->first(\Model\listsSql::first('`id` = '.$did,'`id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`uid`')); | 122 | + $data = $this->db->first(\Model\listsSql::first('`id` = '.$did,'`id`,`to`,`folder_id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`uid`')); |
114 | if($data && $data['is_hots']){ | 123 | if($data && $data['is_hots']){ |
115 | // 在检查下是否是 收件箱 | 124 | // 在检查下是否是 收件箱 |
116 | if($this->db->cache(3600)->value(\Model\folderSql::has(['id'=>$data['folder_id'],'origin_folder'=>'INBOX']))){ | 125 | 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 { | @@ -120,7 +129,9 @@ class fob_hot_ai_mail_auto_reply { | ||
120 | // 验证是否是ai邮箱 | 129 | // 验证是否是ai邮箱 |
121 | if($this->db->count(sprintf("select count(*) from `hot_mail` where `email` = '%s'",$email['email']))){ | 130 | if($this->db->count(sprintf("select count(*) from `hot_mail` where `email` = '%s'",$email['email']))){ |
122 | // 标记已读 | 131 | // 标记已读 |
123 | - $mailInstance = \Lib\Imap\ImapPool::get((new \Lib\Imap\ImapConfig($email))); | 132 | + $email['password'] = base64_decode($email['password']); |
133 | + $email['host'] = $email['imap']; | ||
134 | + $mailInstance = \Lib\Imap\ImapPool::get(new \Lib\Imap\ImapConfig($email)); | ||
124 | if($mailInstance->login()){ | 135 | if($mailInstance->login()){ |
125 | $mailInstance->folder('INBOX')->msg()->uid($data['uid'])->seen(); | 136 | $mailInstance->folder('INBOX')->msg()->uid($data['uid'])->seen(); |
126 | $mailInstance = null; | 137 | $mailInstance = null; |
@@ -129,6 +140,8 @@ class fob_hot_ai_mail_auto_reply { | @@ -129,6 +140,8 @@ class fob_hot_ai_mail_auto_reply { | ||
129 | // 来回超过5次就不回了 | 140 | // 来回超过5次就不回了 |
130 | if(substr_count($data['subject'],"Re:") < 3){ | 141 | if(substr_count($data['subject'],"Re:") < 3){ |
131 | // 有配置才回复 | 142 | // 有配置才回复 |
143 | + $email['hot_email'] = 1; | ||
144 | + $email['password'] = base64_encode($email['password']); | ||
132 | $ret = \Lib\Mail\MailFun::sendEmail([ | 145 | $ret = \Lib\Mail\MailFun::sendEmail([ |
133 | 'subject' => 'Re:'.$data['subject'], | 146 | 'subject' => 'Re:'.$data['subject'], |
134 | 'tos' => [['email'=>$data['from'],'name'=>explode('@',$data['from'])[0]]], | 147 | 'tos' => [['email'=>$data['from'],'name'=>explode('@',$data['from'])[0]]], |
@@ -137,7 +150,8 @@ class fob_hot_ai_mail_auto_reply { | @@ -137,7 +150,8 @@ class fob_hot_ai_mail_auto_reply { | ||
137 | 'Aicc-Hot-Mail' => 'hot' // 预热邮件 | 150 | 'Aicc-Hot-Mail' => 'hot' // 预热邮件 |
138 | ] | 151 | ] |
139 | ],$email); | 152 | ],$email); |
140 | - _echo('回复成功'.$data['id']." ".$email['email'].' to '.$data['from']." ".$ret[1]); | 153 | + |
154 | + _echo(($ret[0]?'回复成功 ':'失败 ').$data['id']." ".$email['email'].' to '.$data['from']." ".$ret[1]); | ||
141 | }else{ | 155 | }else{ |
142 | _echo('来回超过5次就不回了 '.$data['id']); | 156 | _echo('来回超过5次就不回了 '.$data['id']); |
143 | } | 157 | } |
@@ -157,9 +171,19 @@ class fob_hot_ai_mail_auto_reply { | @@ -157,9 +171,19 @@ class fob_hot_ai_mail_auto_reply { | ||
157 | // 随机body内容 | 171 | // 随机body内容 |
158 | $reply = $this->bodys[array_rand($this->bodys)]; | 172 | $reply = $this->bodys[array_rand($this->bodys)]; |
159 | 173 | ||
160 | - return "<pre>------------------ 原始邮件 ------------------ | 174 | + if(rand(1,2)==1){ |
175 | + $reply = "<pre>".$reply."</pre>"; | ||
176 | + }else{ | ||
177 | + $reply = array_map(function ($v){ | ||
178 | + return "<p>".$v."</p>"; | ||
179 | + },explode("\n",$reply)); | ||
180 | + $reply = implode("\n",$reply); | ||
181 | + } | ||
182 | + | ||
183 | + | ||
184 | + return "<pre style='background-color: #e8d6d6;'>------------------ 原始邮件 ------------------ | ||
161 | 发件人: {$data['from']}; | 185 | 发件人: {$data['from']}; |
162 | -发送时间: ".date("Y年m月d日 H:i",$data['udate'])." | 186 | +发送时间: " .date("Y年m月d日 H:i",$data['udate'])." |
163 | 收件人: {$data['to']}; | 187 | 收件人: {$data['to']}; |
164 | 主题: {$data['subject']} | 188 | 主题: {$data['subject']} |
165 | 189 |
-
请 注册 或 登录 后发表评论