Files
fvsjs/include/mail.php
Torsten Schulz e9dae55450 Mail update
2023-07-10 13:10:22 +02:00

41 lines
1.4 KiB
PHP

<?php
require 'vendor/autoload.php';
require 'mailhandling.php';
class Mail extends Mailhandling {
// protected $mbox = null;
protected $folder = '';
protected $uid = 0;
public function __construct(?string $templateName = null) {
parent::__construct();
if (!$this->connectToImap()) {
$this->templateName = 'imaperror';
return;
}
$params = $this->getUriParams();
$this->uid = $params['uid'];
$this->folder = $params['folder'];
$this->content['uid'] = $this->uid;
}
protected function generateContent(): void {
$this->mail = $this->fetchEmail();
$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($messageStructure);
}
protected function renderAttachments($messageStructure): void {
$attachments = $this->mail->getAttachments();
$contentArray = [];
foreach ($attachments as $attachment) {
$contentArray[] = $attachment->name;
}
$this->content['attachments'] = implode('<br>', $contentArray);
}
}