searchMailbox('FROM txt.voice.google.com'); $from_google=true; $cache=Redis::instance(); $i=0; foreach ($mail_ids as $mail_id) { if ($i>=20){ break; }else{ $key="mails_gv:".$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]; $date=$detail->date; }else{ $from_num=str_replace("Message from ", "", $detail->subject); $txt=$detail->textPlain; $rwn=explode("\r\n", $detail->headersRaw); $date=explode(": ", $rwn[2])[1]; } $temp=[ 'from' =>$from_num, 'time' => date("Y-m-d H:i:s",strtotime($date)), 'message' => $txt ]; $cache->set($key, $temp); } $mail_info[]=$temp; } $i++; } krsort($mail_info); return $mail_info; } }