X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/b04f76050d54c67844d5d4026993f6fab0edeae5..b3e01444d0f6253ae14d6223daa325686718fb63:/mail/index.php?ds=inline
diff --git a/mail/index.php b/mail/index.php
index 37b1edc..d4d4c29 100644
--- a/mail/index.php
+++ b/mail/index.php
@@ -6,8 +6,10 @@ 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'] = mailparse_rfc822_parse_addresses($headlist['From']);
- //TODO: imap_rfc822_parse_adrlist() alternative
+ $headlist['from'] = imap_rfc822_parse_adrlist($headlist['From'], '');
+ array_walk($headlist['from'], function ($row) {
+ $row->display = $row->personal ?? $row->mailbox;
+ });
return $headlist;
}
@@ -15,13 +17,17 @@ if ($msgid) {
$filename = "$mailbox/$msgid";
list ($headerdata, $rawbody) = explode("\n\n", file_get_contents($filename), 2);
$head = parsemailhead($headerdata);
+ $head['date']->setTimezone(new DateTimeZone(date_default_timezone_get()));
$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'][0]['display']));
+ printf(''."\n",
+ htmlspecialchars($head['From']),
+ htmlspecialchars(implode(', ', array_column($head['from'], 'display'))),
+ htmlspecialchars($head['Date']),
+ showdate(preg_split('/\D/', $head['date']->format('c')))
+ );
print '
';
if (preg_match('{^text/plain}', $head['Content-Type'] ?? 'text/plain')) {
@@ -59,16 +65,24 @@ array_splice($rows, 0, -50);
ob_start();
print '';
foreach (array_reverse($rows) as $filename) {
- list ($headerdata) = explode("\n\n", file_get_contents($filename));
- $head = parsemailhead($headerdata);
+ if (!is_readable($filename)) {
+ continue;
+ }
printf('- ', "/{$Page->handler}/".basename($filename));
+ list ($headerdata) = explode("\n\n", file_get_contents($filename));
+ $head = parsemailhead($headerdata);
+
print $head['Subject'];
- printf(' %s',
+ printf(' %s',
+ htmlspecialchars($head['Date']),
showdate(explode('-', $head['date']->format('Y-m-d')))
);
- print ' '.htmlspecialchars($head['from'][0]['display']).'';
+ printf(' %s',
+ htmlspecialchars($head['From']),
+ htmlspecialchars(implode(', ', array_column($head['from'], 'display')))
+ );
print "
\n";
}
print "
\n";