作者 邓超

自动回复 把邮件从垃圾箱移到收件箱

... ... @@ -92,7 +92,7 @@ class fob_ai_mail_auto_reply {
// 检查是否是垃圾箱
$folder = $this->db->cache(3600)->first(folderSql::first($data['folder_id']));
$folder = $this->db->throw()->cache(3600)->first(folderSql::first($data['folder_id']));
if($folder['folder'] == '垃圾箱'){
$email = $this->db->throw()->cache(3600)->first(\Model\emailSql::first($data['email_id']));
... ... @@ -107,18 +107,20 @@ class fob_ai_mail_auto_reply {
$email['password'] = base64_decode($email['password']);
$email['host'] = $email['imap'];
$mailInstance = \Lib\Imap\ImapPool::get((new \Lib\Imap\ImapConfig($email)));
$msg = $mailInstance->folder($folder['origin_folder'])->msg()->uid($data['uid']);
if(!$msg->move('INBOX')){
if(!$msg->copy('INBOX')){
@file_put_contents(__DIR__."/move_log.log",'移动邮件失败'.json_encode($data,JSON_UNESCAPED_UNICODE)."\n",FILE_APPEND);
$ok = false;
_echo("垃圾邮件移动失败 ".$data['id'].' '.$data['subject']);
if($mailInstance->login()){
$msg = $mailInstance->folder($folder['origin_folder'])->msg()->uid($data['uid']);
if(!$msg->move('INBOX')){
if(!$msg->copy('INBOX')){
@file_put_contents(__DIR__."/move_log.log",'移动邮件失败'.json_encode($data,JSON_UNESCAPED_UNICODE)."\n",FILE_APPEND);
$ok = false;
_echo("垃圾邮件移动失败 ".$data['id'].' '.$data['subject']);
}
}
if($ok) {
_echo("垃圾邮件移动成功 ".$data['id'].' '.$data['subject']);
}
$mailInstance = null;
}
if($ok) {
_echo("垃圾邮件移动成功 ".$data['id'].' '.$data['subject']);
}
$mailInstance = null;
}
continue;
... ...