Mailbox update

This commit is contained in:
Torsten Schulz
2023-06-16 13:53:35 +02:00
parent 0bd00d552f
commit 7e4ac1bd1b
2 changed files with 5 additions and 9 deletions

View File

@@ -3,10 +3,12 @@ require 'renderer.php';
require 'vendor/autoload.php'; require 'vendor/autoload.php';
class Emailinbox extends Renderer { class Emailinbox extends Renderer {
private string $folder = 'INBOX';
public function __construct(?string $templateName = null) { public function __construct(?string $templateName = null) {
parent::__construct(); parent::__construct();
if (!$this->connectToImap()) { $folder = $filter_input(INPUT_GET, 'folder') ?? 'INBOX';
if (!$this->connectToImap($folder)) {
$this->templateName = 'imaperror'; $this->templateName = 'imaperror';
} }
} }
@@ -68,6 +70,5 @@ class Emailinbox extends Renderer {
$folderItems[] = '<li><a href="/emailinbox?folder=' . urlencode($folder['shortpath']) . '">' . utf8_encode($folder['shortpath']) . '</a></li>'; $folderItems[] = '<li><a href="/emailinbox?folder=' . urlencode($folder['shortpath']) . '">' . utf8_encode($folder['shortpath']) . '</a></li>';
} }
$this->content['folders'] = implode('', $folderItems); $this->content['folders'] = implode('', $folderItems);
// var_dump($folders);
} }
} }

View File

@@ -451,9 +451,9 @@ class Renderer {
$mail->send(); $mail->send();
} }
protected function connectToImap(): bool { protected function connectToImap($folder = ''): bool {
$this->mbox = new PhpImap\Mailbox( $this->mbox = new PhpImap\Mailbox(
'{' . $this->imapServer . ':' . $this->imapPort . '/imap/ssl}', '{' . $this->imapServer . ':' . $this->imapPort . '/imap/ssl}' . $folder,
$this->emailUser, $this->emailUser,
$this->emailPassword, $this->emailPassword,
__DIR__, __DIR__,
@@ -466,11 +466,6 @@ class Renderer {
3, 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); return ($this->mbox !== false);
} }