Overworked mailbox

This commit is contained in:
Torsten Schulz
2023-10-16 19:12:08 +02:00
parent f70d6d1224
commit c97239f1fc
3 changed files with 40 additions and 13 deletions

View File

@@ -20,19 +20,21 @@ 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');
$this->content['emailbody'] = $this->mail->textHtml ?? $this->mail->textPlain;
$this->content['subject'] = $this->mail->subject;
$this->renderAttachments();
$folder = $this->mbox->getFolderByName($this->folder);
$message = $folder->query()->getMessageByUid($this->uid);
if (!$message) {
return;
}
$this->content['subject'] = $message->subject;
$this->content['sender'] = $message->getHeader()->decode($message->from);
$this->content['receiver'] = $message->getHeader()->decode($message->to);
$this->content['senddate'] = $message->date->toDate()->format('d.m.Y');
$this->content['emailbody'] = $message->hasHTMLBody() ? $message->getHTMLBody() : $message->getTextBody();
$this->renderAttachments($message);
}
protected function renderAttachments(): void {
$attachments = $this->mail->getAttachments();
protected function renderAttachments($message): void {
$attachments = $message->getAttachments();
$contentArray = [];
foreach ($attachments as $attachment) {
$contentArray[] = $attachment->name;