From 7e4ac1bd1bc15855287a2b7f02be8eab42e957ad Mon Sep 17 00:00:00 2001 From: Torsten Schulz Date: Fri, 16 Jun 2023 13:53:35 +0200 Subject: [PATCH] Mailbox update --- include/emailinbox.php | 5 +++-- include/renderer.php | 9 ++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/emailinbox.php b/include/emailinbox.php index a4f82bc..835c343 100644 --- a/include/emailinbox.php +++ b/include/emailinbox.php @@ -3,10 +3,12 @@ require 'renderer.php'; require 'vendor/autoload.php'; class Emailinbox extends Renderer { + private string $folder = 'INBOX'; public function __construct(?string $templateName = null) { parent::__construct(); - if (!$this->connectToImap()) { + $folder = $filter_input(INPUT_GET, 'folder') ?? 'INBOX'; + if (!$this->connectToImap($folder)) { $this->templateName = 'imaperror'; } } @@ -68,6 +70,5 @@ class Emailinbox extends Renderer { $folderItems[] = '
  • ' . utf8_encode($folder['shortpath']) . '
  • '; } $this->content['folders'] = implode('', $folderItems); - // var_dump($folders); } } diff --git a/include/renderer.php b/include/renderer.php index 909b4df..bdd453c 100644 --- a/include/renderer.php +++ b/include/renderer.php @@ -451,9 +451,9 @@ class Renderer { $mail->send(); } - protected function connectToImap(): bool { + protected function connectToImap($folder = ''): bool { $this->mbox = new PhpImap\Mailbox( - '{' . $this->imapServer . ':' . $this->imapPort . '/imap/ssl}', + '{' . $this->imapServer . ':' . $this->imapPort . '/imap/ssl}' . $folder, $this->emailUser, $this->emailPassword, __DIR__, @@ -466,11 +466,6 @@ class Renderer { 3, [] ); -/* $this->mbox = imap_open ("{" . $this->imapServer . ":" . $this->imapPort . "/imap/ssl}INBOX", $this->emailUser, $this->emailPassword); - if ($this->mbox === false) { - $errors = imap_errors(); - $this->errors = is_array($errors) ? $errors : [$errors]; - }*/ return ($this->mbox !== false); }