path, '/')); function parsemailhead($headerdata) { $headlist = iconv_mime_decode_headers($headerdata, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); $headlist['date'] = DateTime::createFromFormat(DateTimeInterface::RFC2822.'+', $headlist['Date']); $headlist['from'] = imap_rfc822_parse_adrlist($headlist['From'], ''); array_walk($headlist['from'], function ($row) { $row->display = $row->personal ?? $row->mailbox; }); return $headlist; } if ($msgid) { $filename = "$mailbox/$msgid"; list ($headerdata, $rawbody) = explode("\n\n", file_get_contents($filename), 2); $head = parsemailhead($headerdata); $Page->title = 'Mailbericht ' . $head['date']->format('Y-m-d H:i'); printf("

%s

\n", htmlspecialchars($head['Subject'] ?? 'Mailbericht zonder onderwerp')); print '
'; printf('
Ontvangen:
%s
', $head['date']->format('c')); printf('
Verzender:
%s
', htmlspecialchars($head['From'])); print '
'; if (preg_match('{^text/plain}', $head['Content-Type'] ?? 'text/plain')) { $body = $rawbody; if (($head['Content-Transfer-Encoding'] ?? '') === 'quoted-printable') { $body = quoted_printable_decode($body); } printf('
%s
', htmlspecialchars($body)); } else { printf('

Geen ondersteuning voor %s.

', htmlspecialchars($head['Content-Type'])); /* TODO $mime = mailparse_msg_parse_file($filename); $part = mailparse_msg_get_part($mime, '1'); mailparse_msg_extract_part_file($part, $filename); */ } return; } if (!$User->admin('user')) { http_response_code(403); $Page->place['warn'] = "Geen gebruikersrechten om e-mails in te zien."; $Page->place['maillist'] = ''; return TRUE; } $rows = glob("$mailbox/*"); if (!$rows) { throw new Exception('Kon inbox niet openen.'); } array_splice($rows, 0, -50); ob_start(); print '\n"; $Page->place['maillist'] = ob_get_clean();