WIP - New imap class

This commit is contained in:
Torsten Schulz
2023-10-16 15:41:05 +02:00
parent 54d30dd3c3
commit 6a9717e0db
165 changed files with 7347 additions and 10527 deletions

View File

@@ -14,6 +14,7 @@ class Emailinbox extends Renderer {
}
protected function readEmailHeaders(): array {
return [];
$cleanedHeaders = [];
try {
$mailsIds = $this->mbox->searchMailbox('ALL');
@@ -69,12 +70,12 @@ class Emailinbox extends Renderer {
protected function generateFolders(): void {
$this->connectToImap();
$folders = $this->mbox->getMailboxes("*");
$folders = $this->mbox->generateFolders();
$folderItems = [];
foreach ($folders as $folder) {
$item = '<li><a href="/emailinbox?folder=' . urlencode($folder['shortpath']) . '"' .
(utf8_encode($folder['shortpath']) === $this->folder ? ' class="active-folder"' : '') . '>' .
utf8_encode($folder['shortpath']) . '</a></li>';
$item = '<li><a href="/emailinbox?folder=' . urlencode($folder->name) . '"' .
(utf8_encode($folder->name) === $this->folder ? ' class="active-folder"' : '') . '>' .
utf8_encode($folder->full_name) . '</a></li>';
$folderItems[] = $item;
}
$this->content['folders'] = implode('', $folderItems);

View File

@@ -21,6 +21,8 @@ class Mail extends Mailhandling {
protected function generateContent(): void {
$this->mail = $this->fetchEmail();
$textHtml = $this->mail->textHtml;
$textPlain = $this->mail->textPlain;
$this->content['sender'] = $this->mail->headers->senderaddress;
$this->content['receiver'] = $this->mail->headers->toaddress;
$this->content['senddate'] = (new DateTime($this->mail->date))->format('d.m.Y');

View File

@@ -2,7 +2,8 @@
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
use PhpImap\Mailbox;
use Webklex\PHPIMAP\ClientManager;
use Webklex\PHPIMAP\Client;
require 'vendor/autoload.php';
@@ -34,7 +35,8 @@ class Renderer {
protected int $smtpPort = 465;
protected string $emailUser = 'foerderverein-ajs@gmx.de';
protected string $emailPassword = 'HarheimerWeg16';
protected $mbox;
protected ClientManager $imapClientManager;
protected Client $mbox;
public function __construct(?string $templateName = null) {
session_start();
@@ -452,21 +454,18 @@ class Renderer {
}
protected function connectToImap($folder = ''): bool {
$this->mbox = new PhpImap\Mailbox(
'{' . $this->imapServer . ':' . $this->imapPort . '/imap/ssl}' . imap_utf7_encode($folder),
$this->emailUser,
$this->emailPassword,
__DIR__,
'UTF-8',
true,
false
);
$this->mbox->setConnectionArgs(
CL_EXPUNGE,
3,
[]
);
return ($this->mbox !== false);
$this->imapClientManager = new ClientManager('conf/imap.php');
$this->mbox = $this->imapClientManager->make([
'host' => $this->imapServer,
'port' => $this->imapPort,
'encryption' => 'ssl',
'validate_cert' => true,
'username' => $this->emailUser,
'password' => $this->emailPassword,
'protocol' => 'imap'
]);
$this->mbox->connect();
return $this->mbox->isConnected();;
}
protected function saveFileLocal(string $newFileName, string $content, string $salt): void {