41 lines
1.4 KiB
PHP
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 = urldecode($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();
|
|
}
|
|
|
|
protected function renderAttachments(): void {
|
|
$attachments = $this->mail->getAttachments();
|
|
$contentArray = [];
|
|
foreach ($attachments as $attachment) {
|
|
$contentArray[] = $attachment->name;
|
|
}
|
|
$this->content['attachments'] = implode('<br>', $contentArray);
|
|
}
|
|
}
|