getQuery()->string("num","6288883915"); $from_google=false; if ($num=="6288883915"){ $mail_ids = $mailbox->searchMailbox('FROM txt.voice.google.com'); $from_google=true; }else{ if ($num=="6285000156"){ $mail_ids = $mailbox->searchMailbox('FROM textnow.me'); $from_google=false; } } // $mail_info = $mailbox->getMailsInfo($mail_ids); $mail_info=[]; $mail_ids=array_reverse($mail_ids); $i=0; // $cache = new FileCache([ // 'root' => APP_DIR.'/cache', // Cache root // 'ttl' => 0, // Time to live // 'compress' => false, // Compress data with gzcompress or not // 'serialize' => 'json', // How to serialize data: json, php, raw // ]); $cache=Redis::instance(); foreach ($mail_ids as $mail_id) { if ($i>=5){ break; }else{ $key="mails:".$mail_id; $temp=$cache->get($key); if (!$temp) { $detail = $mailbox->getMail($mail_id); if ($from_google){ $from_num=$detail->fromName; $txt = explode("\r\n", $detail->textPlain)[1]; }else{ $from_num=str_replace("Message from ", "", $detail->subject); $txt=$detail->textPlain; } $temp = [ 'subject' => $detail->subject, 'content' => $txt, 'from' => $detail->fromAddress, 'fromName' => $from_num, 'replyTo' => $detail->replyTo, 'date' =>$detail->date, 'cc' => $detail->cc, 'bcc' => $detail->bcc, ]; $cache->set($key, $temp); } $mail_info[]=$temp; } $i++; } $this->result=$mail_info; $this->num=$num; $this->render(); } }