Overworked mailbox
This commit is contained in:
@@ -24,10 +24,10 @@ class Emailinbox extends Renderer {
|
|||||||
$date = $header->getDate()->toDate();
|
$date = $header->getDate()->toDate();
|
||||||
$flags = $message->getFlags();
|
$flags = $message->getFlags();
|
||||||
$cleanedHeaders[$message->getUid()] = [
|
$cleanedHeaders[$message->getUid()] = [
|
||||||
'title' => $header->subject,
|
'title' => $message->subject,
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'unread' => !isset($flags['seen']) || $flags['seen'] != 'Seen',
|
'unread' => !isset($flags['seen']) || $flags['seen'] != 'Seen',
|
||||||
'from' => $header->from,
|
'from' => $header->decode($header->from),
|
||||||
];
|
];
|
||||||
} catch (\exception $err) {
|
} catch (\exception $err) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,19 +20,21 @@ class Mail extends Mailhandling {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function generateContent(): void {
|
protected function generateContent(): void {
|
||||||
$this->mail = $this->fetchEmail();
|
$folder = $this->mbox->getFolderByName($this->folder);
|
||||||
$textHtml = $this->mail->textHtml;
|
$message = $folder->query()->getMessageByUid($this->uid);
|
||||||
$textPlain = $this->mail->textPlain;
|
if (!$message) {
|
||||||
$this->content['sender'] = $this->mail->headers->senderaddress;
|
return;
|
||||||
$this->content['receiver'] = $this->mail->headers->toaddress;
|
}
|
||||||
$this->content['senddate'] = (new DateTime($this->mail->date))->format('d.m.Y');
|
$this->content['subject'] = $message->subject;
|
||||||
$this->content['emailbody'] = $this->mail->textHtml ?? $this->mail->textPlain;
|
$this->content['sender'] = $message->getHeader()->decode($message->from);
|
||||||
$this->content['subject'] = $this->mail->subject;
|
$this->content['receiver'] = $message->getHeader()->decode($message->to);
|
||||||
$this->renderAttachments();
|
$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 {
|
protected function renderAttachments($message): void {
|
||||||
$attachments = $this->mail->getAttachments();
|
$attachments = $message->getAttachments();
|
||||||
$contentArray = [];
|
$contentArray = [];
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
$contentArray[] = $attachment->name;
|
$contentArray[] = $attachment->name;
|
||||||
|
|||||||
@@ -508,4 +508,29 @@ class Renderer {
|
|||||||
return htmlspecialchars($name . ' (' . $row['description'] . ')');
|
return htmlspecialchars($name . ' (' . $row['description'] . ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decodeSubject($subject) {
|
||||||
|
return $subject;
|
||||||
|
// Match the encoding and encoded string using a regular expression
|
||||||
|
preg_match_all('/=\?([^?]+)\?([QB])\?([^?]+)\?=/i', $subject, $matches, PREG_SET_ORDER);
|
||||||
|
|
||||||
|
$decoded = '';
|
||||||
|
foreach ($matches as $match) {
|
||||||
|
$encoding = $match[1];
|
||||||
|
$type = $match[2];
|
||||||
|
$encoded_string = $match[3];
|
||||||
|
if ($type == 'Q') {
|
||||||
|
$decoded_part = quoted_printable_decode($encoded_string);
|
||||||
|
} elseif ($type == 'B') {
|
||||||
|
$decoded_part = base64_decode($encoded_string);
|
||||||
|
}
|
||||||
|
var_dump($match);
|
||||||
|
if (strtolower($encoding) != 'utf-8') {
|
||||||
|
$decoded_part = iconv($encoding, 'UTF-8', $decoded_part);
|
||||||
|
}
|
||||||
|
$decoded .= str_replace('_', ' ', $decoded_part);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $decoded;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user