public function getList() { //$emails = imap_search($stream, 'SINCE '. date('d-M-Y',strtotime("-1 week"))); $emails = imap_search($this->conn, 'ALL'); $articles = array(); if (count($emails)) { rsort($emails); foreach ($emails as $email) { // Fetch the email's overview and show subject, from and date. $overview = imap_fetch_overview($this->conn, $email, 0); echo $overview[0]->uid . ' : '; $structure = imap_fetchstructure($this->conn, $overview[0]->uid, FT_UID); if ($structure->encoding == "3") { $body = base64_decode(imap_fetchbody($this->conn, imap_msgno($this->conn, $overview[0]->uid), 1)); } elseif ($structure->encoding == "0") { $body = imap_qprint(imap_fetchbody($this->conn, imap_msgno($this->conn, $overview[0]->uid), 1)); } elseif ($structure->encoding == "1") { $body = imap_fetchbody($this->conn, imap_msgno($this->conn, $overview[0]->uid), 1); } elseif ($structure->encoding == "4") { $body = imap_qprint(imap_fetchbody($this->conn, imap_msgno($this->conn, $overview[0]->uid), 1)); } else { $body = imap_fetchbody($this->conn, imap_msgno($this->conn, $overview[0]->uid), 1); } $article = new ArticleEntity(); $article->setTitle("\$\$\$\$" . $structure->encoding . "\$\$\$" . $this->decode_imap_text($overview[0]->subject) . ' - ' . $this->decode_imap_text($overview[0]->from)); $article->setContent($this->getBody($overview[0]->uid, $this->conn)); $article->setDate($overview[0]->date); $articles[] = $article; } } return $articles; }