diff --git a/include/emailinbox.php b/include/emailinbox.php index 934ead1..7c084aa 100644 --- a/include/emailinbox.php +++ b/include/emailinbox.php @@ -7,27 +7,19 @@ class Emailinbox extends Renderer { public function __construct(?string $templateName = null) { parent::__construct(); - $this->folder = utf8_encode(urldecode(filter_input(INPUT_GET, 'folder'))) ?? 'INBOX'; + $this->folder = urldecode(filter_input(INPUT_GET, 'folder')) ?? ''; if (!$this->connectToImap($this->folder)) { $this->templateName = 'imaperror'; } } protected function readEmailHeaders(): array { - return []; $cleanedHeaders = []; - try { - $mailsIds = $this->mbox->searchMailbox('ALL'); - } catch(PhpImap\Exceptions\ConnectionException $ex) { - echo "IMAP connection failed: " . implode(",", $ex->getErrors('all')); - die(); - } - if (!$mailsIds) { - return []; - } - $headers = $this->mbox->getMailsInfo($mailsIds); + $folder = $this->mbox->getFolderByName($this->folder); + $headers = $folder->messages(); foreach ($headers as $header) { - try { + var_dump($header); +/* try { $date = \DateTime::createFromFormat('D, d M Y H:i:s O', str_replace([' (CET)', ' (CEST)', ' (UTC)'], '' , $header->date)); // if (!$date) { // var_dump($header->date); @@ -40,7 +32,7 @@ class Emailinbox extends Renderer { 'unread' => !$header->seen, ]; } catch (\exception $err) { - } + }*/ } return $cleanedHeaders; }