Mail update
This commit is contained in:
@@ -20,9 +20,8 @@ class Mail extends Mailhandling {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function generateContent(): void {
|
protected function generateContent(): void {
|
||||||
// $messageStructure = imap_fetchstructure($this->mbox, $this->uid);
|
$this->mail = $this->fetchEmail();
|
||||||
$this->fetchEmailHeader($this->content);
|
$this->content['sender'] = $this->mail->headers->senderaddress;
|
||||||
$this->fetchEmailBody($messageStructure, $this->content, 'INBOX', FT_PEEK);
|
|
||||||
$this->renderAttachments($messageStructure);
|
$this->renderAttachments($messageStructure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,30 +11,12 @@ class Mailhandling extends Renderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fetchEmailHeader(array &$content): void {
|
protected function fetchEmail(array &$content): PhpImap\IncomingMail {
|
||||||
$mailsIds = $this->mbox->searchMailbox('ALL');
|
$mailsIds = $this->mbox->searchMailbox('ALL');
|
||||||
$mail = $this->mbox->getMail($mailsIds[0]); //$this->uid, false);
|
$mail = $this->mbox->getMail($mailsIds[0]); //$this->uid, false);
|
||||||
var_dump($mail);die;
|
return $mail;
|
||||||
$content['sender'] = imap_utf8($header->fromaddress);
|
|
||||||
$content['receiver'] = imap_utf8($header->toaddress);
|
|
||||||
$content['subject'] = imap_utf8($header->subject);
|
|
||||||
$content['senddate'] = date('d.m.Y H:i:s', strtotime($header->date));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fetchEmailBody($messageStructure, array &$content): void {
|
|
||||||
$message = imap_fetchbody($this->mbox, $this->uid, 1.1, FT_PEEK);
|
|
||||||
if($message == '') {
|
|
||||||
$message = imap_fetchbody($this->mbox, $this->uid, 1, FT_PEEK);
|
|
||||||
}
|
|
||||||
$decodedMessage = quoted_printable_decode($message);
|
|
||||||
if (isset($messageStructure->parts) && isset($messageStructure->parts[1]) && isset($messageStructure->parts[1]->parameters)
|
|
||||||
&& isset($messageStructure->parts[1]->parameters) && is_array($messageStructure->parts[1]->parameters) && isset($messageStructure->parts[1]->parameters[0]->value) && strtolower($messageStructure->parts[1]->parameters[0]->value) != 'utf-8') {
|
|
||||||
$decodedMessage = utf8_encode($decodedMessage);
|
|
||||||
}
|
|
||||||
$content['emailbody'] = nl2br($decodedMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function getAttachments($structure): array {
|
protected function getAttachments($structure): array {
|
||||||
$attachments = [];
|
$attachments = [];
|
||||||
if(isset($structure->parts) && count($structure->parts)) {
|
if(isset($structure->parts) && count($structure->parts)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user