2017-09-09 08:40:07 +00:00
|
|
|
<?php require '../config.php'; ?>
|
|
|
|
<?php loadClass('Helper')->authPage(); ?>
|
2016-10-30 13:40:29 +00:00
|
|
|
<?php
|
|
|
|
|
2016-11-05 01:57:10 +00:00
|
|
|
//
|
|
|
|
// $_POST submit for sending a test email
|
|
|
|
//
|
2022-02-15 11:08:27 +00:00
|
|
|
if (isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['message'])) {
|
|
|
|
$mail = $_POST['email'];
|
|
|
|
$subj = $_POST['subject'];
|
|
|
|
$mess = $_POST['message'];
|
2017-04-19 17:48:44 +00:00
|
|
|
if (! mail($mail, $subj, $mess)) {
|
2017-11-04 12:42:41 +00:00
|
|
|
loadClass('Logger')->error('Could not send mail to: '.$mail.' | subject: '.$subj);
|
2017-04-19 17:48:44 +00:00
|
|
|
}
|
2016-10-30 13:40:29 +00:00
|
|
|
header('Location: /mail.php');
|
2016-11-05 01:57:10 +00:00
|
|
|
exit();
|
2016-10-30 13:40:29 +00:00
|
|
|
}
|
|
|
|
|
2016-11-05 01:57:10 +00:00
|
|
|
//
|
|
|
|
// Includes
|
|
|
|
//
|
2016-11-06 16:21:59 +00:00
|
|
|
require $VEN_DIR . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR .'Mbox.php';
|
|
|
|
require $VEN_DIR . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR .'mimeDecode.php';
|
|
|
|
require $LIB_DIR . DIRECTORY_SEPARATOR . 'Mail.php';
|
|
|
|
require $LIB_DIR . DIRECTORY_SEPARATOR . 'Sort.php';
|
2016-11-05 01:57:10 +00:00
|
|
|
|
2022-01-30 13:27:08 +00:00
|
|
|
|
|
|
|
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
|
|
|
|
$message = $_GET['delete'];
|
|
|
|
$MyMbox = new \devilbox\Mail('/var/mail/devilbox');
|
|
|
|
$MyMbox->delete($message);
|
|
|
|
header('Location: /mail.php');
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-05 01:57:10 +00:00
|
|
|
//
|
|
|
|
// Setup Sort/Order
|
|
|
|
//
|
|
|
|
|
|
|
|
// Sort/Order settings
|
|
|
|
$defaultSort = array('sort' => 'date', 'order' => 'DESC');
|
2017-12-06 04:04:33 +00:00
|
|
|
$allowedSorts = array('date', 'subject', 'x-original-to', 'from');
|
2016-11-05 01:57:10 +00:00
|
|
|
$allowedOrders = array('ASC', 'DESC');
|
|
|
|
$GET_sortKeys = array('sort' => 'sort', 'order' => 'order');
|
|
|
|
|
|
|
|
// Get sort/order
|
|
|
|
$MySort = new \devilbox\Sort($defaultSort, $allowedSorts, $allowedOrders, $GET_sortKeys);
|
|
|
|
$sort = $MySort->getSort();
|
|
|
|
$order = $MySort->getOrder();
|
|
|
|
|
|
|
|
// Evaluate Sorters/Orderers
|
2016-11-15 18:39:11 +00:00
|
|
|
$orderDate = '<a href="/mail.php?sort=date&order=ASC"><i class="fa fa-sort" aria-hidden="true"></i></a>';
|
2017-12-06 04:04:33 +00:00
|
|
|
$orderFrom = '<a href="/mail.php?sort=from&order=ASC"><i class="fa fa-sort" aria-hidden="true"></i></a>';
|
2016-11-15 18:39:11 +00:00
|
|
|
$orderTo = '<a href="/mail.php?sort=x-original-to&order=ASC"><i class="fa fa-sort" aria-hidden="true"></i></a>';
|
|
|
|
$orderSubj = '<a href="/mail.php?sort=subject&order=ASC"><i class="fa fa-sort" aria-hidden="true"></i></a>';
|
2016-11-05 01:57:10 +00:00
|
|
|
|
|
|
|
if ($sort == 'date') {
|
|
|
|
if ($order == 'ASC') {
|
2016-11-15 18:39:11 +00:00
|
|
|
$orderDate = '<a href="/mail.php?sort=date&order=DESC"><i class="fa fa-sort" aria-hidden="true"></i></a> <i class="fa fa-sort-numeric-asc" aria-hidden="true"></i>';
|
2016-11-05 01:57:10 +00:00
|
|
|
} else {
|
2016-11-15 18:39:11 +00:00
|
|
|
$orderDate = '<a href="/mail.php?sort=date&order=ASC"><i class="fa fa-sort" aria-hidden="true"></i></a> <i class="fa fa-sort-numeric-desc" aria-hidden="true"></i> ';
|
2016-11-05 01:57:10 +00:00
|
|
|
}
|
|
|
|
} else if ($sort == 'subject') {
|
|
|
|
if ($order == 'ASC') {
|
2016-11-15 18:39:11 +00:00
|
|
|
$orderSubj = '<a href="/mail.php?sort=subject&order=DESC"><i class="fa fa-sort" aria-hidden="true"></i></a> <i class="fa fa-sort-alpha-asc" aria-hidden="true"></i>';
|
2016-11-05 01:57:10 +00:00
|
|
|
} else {
|
2016-11-15 18:39:11 +00:00
|
|
|
$orderSubj = '<a href="/mail.php?sort=subject&order=ASC"><i class="fa fa-sort" aria-hidden="true"></i></a> <i class="fa fa-sort-alpha-desc" aria-hidden="true"></i>';
|
2016-11-05 01:57:10 +00:00
|
|
|
}
|
|
|
|
} else if ($sort == 'x-original-to') {
|
|
|
|
if ($order == 'ASC') {
|
2016-11-15 18:39:11 +00:00
|
|
|
$orderTo = '<a href="/mail.php?sort=x-original-to&order=DESC"><i class="fa fa-sort" aria-hidden="true"></i></a> <i class="fa fa-sort-alpha-asc" aria-hidden="true"></i>';
|
2016-11-05 01:57:10 +00:00
|
|
|
} else {
|
2016-11-15 18:39:11 +00:00
|
|
|
$orderTo = '<a href="/mail.php?sort=x-original-to&order=ASC"><i class="fa fa-sort" aria-hidden="true"></i></a> <i class="fa fa-sort-alpha-desc" aria-hidden="true"></i>';
|
2016-11-05 01:57:10 +00:00
|
|
|
}
|
2017-12-06 04:04:33 +00:00
|
|
|
} else if ($sort == 'from') {
|
|
|
|
if ($order == 'ASC') {
|
|
|
|
$orderFrom = '<a href="/mail.php?sort=from&order=DESC"><i class="fa fa-sort" aria-hidden="true"></i></a> <i class="fa fa-sort-alpha-asc" aria-hidden="true"></i>';
|
|
|
|
} else {
|
|
|
|
$orderFrom = '<a href="/mail.php?sort=from&order=ASC"><i class="fa fa-sort" aria-hidden="true"></i></a> <i class="fa fa-sort-alpha-desc" aria-hidden="true"></i>';
|
|
|
|
}
|
2016-11-05 01:57:10 +00:00
|
|
|
}
|
|
|
|
|
2016-10-30 13:40:29 +00:00
|
|
|
|
2016-11-05 01:57:10 +00:00
|
|
|
//
|
|
|
|
// Mbox Reader
|
|
|
|
//
|
2017-05-06 09:14:01 +00:00
|
|
|
$MyMbox = new \devilbox\Mail('/var/mail/devilbox');
|
2016-10-30 13:40:29 +00:00
|
|
|
|
2016-11-05 01:57:10 +00:00
|
|
|
// If default sort is on, use NULL, so we do not have to sort the mails after retrieval,
|
|
|
|
// because they are being read in the default sort/order anyway
|
|
|
|
$sortOrderArr = $MySort->isDefault($sort, $order) ? null : array($sort => $order);
|
|
|
|
$messages = $MyMbox->get($sortOrderArr);
|
2016-10-30 13:40:29 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2017-05-15 06:56:17 +00:00
|
|
|
<?php echo loadClass('Html')->getHead(true); ?>
|
2016-10-30 13:40:29 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2017-05-15 06:56:17 +00:00
|
|
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
2016-10-30 13:40:29 +00:00
|
|
|
|
|
|
|
<div class="container">
|
|
|
|
<h1>Mail</h1>
|
|
|
|
<br/>
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
<h3>Send test Email</h3>
|
|
|
|
<br/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
|
2022-02-15 11:08:27 +00:00
|
|
|
<form method="post" class="form-inline">
|
2016-10-30 13:40:29 +00:00
|
|
|
<div class="form-group">
|
|
|
|
<label class="sr-only" for="exampleInputEmail1">Email to</label>
|
|
|
|
<input name="email" type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter to email">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="sr-only" for="exampleInputEmail2">Subject</label>
|
|
|
|
<input name="subject" type="text" class="form-control" id="exampleInputEmail2" placeholder="Subject">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="sr-only" for="exampleInputEmail3">Message</label>
|
2022-02-15 11:08:27 +00:00
|
|
|
<textarea name="message" rows="1" class="form-control" id="exampleInputEmail3" placeholder="Message"></textarea>
|
2016-10-30 13:40:29 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<button type="submit" class="btn btn-primary">Send Email</button>
|
|
|
|
</form>
|
|
|
|
<br/>
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
2016-11-15 18:39:11 +00:00
|
|
|
<h3>Received Emails</h3>
|
2016-10-30 13:40:29 +00:00
|
|
|
<br/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2016-11-05 01:57:10 +00:00
|
|
|
|
2016-10-30 13:40:29 +00:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
<table class="table table-striped table-hover">
|
|
|
|
<thead class="thead-inverse">
|
|
|
|
<tr>
|
|
|
|
<th>#</th>
|
2016-11-05 01:57:10 +00:00
|
|
|
<th>Date <?php echo $orderDate;?></th>
|
2017-12-06 04:04:33 +00:00
|
|
|
<th>From <?php echo $orderFrom;?></th>
|
2016-11-05 01:57:10 +00:00
|
|
|
<th>To <?php echo $orderTo;?></th>
|
|
|
|
<th>Subject <?php echo $orderSubj;?></th>
|
2022-01-30 13:27:08 +00:00
|
|
|
<th>Action</th>
|
2016-10-30 13:40:29 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2016-11-05 01:57:10 +00:00
|
|
|
<?php foreach ($messages as $data): ?>
|
2016-10-30 13:40:29 +00:00
|
|
|
<?php
|
2018-07-28 07:21:43 +00:00
|
|
|
$message = htmlentities($data['raw']);
|
2016-11-05 01:57:10 +00:00
|
|
|
$structure = $data['decoded'];
|
2021-02-21 13:40:16 +00:00
|
|
|
$body = null;
|
|
|
|
|
|
|
|
if (isset($structure->body)) {
|
|
|
|
$body = $structure->body;
|
|
|
|
}
|
|
|
|
elseif(isset($structure->parts[1]->body)) {
|
|
|
|
$body = $structure->parts[1]->body;
|
|
|
|
}
|
|
|
|
elseif(isset($structure->parts[0]->body)) {
|
|
|
|
$body = $structure->parts[0]->body;
|
|
|
|
}
|
2016-10-30 13:40:29 +00:00
|
|
|
?>
|
2016-11-05 01:57:10 +00:00
|
|
|
<tr id="<?php echo $data['num'];?>" class="subject">
|
|
|
|
<td><?php echo $data['num'];?></td>
|
2016-10-30 13:40:29 +00:00
|
|
|
<td>
|
|
|
|
<?php echo date('H:i', strtotime($structure->headers['date']));?><br/>
|
|
|
|
<small><?php echo date('Y-m-d', strtotime($structure->headers['date']));?></small>
|
|
|
|
</td>
|
2017-12-06 04:04:33 +00:00
|
|
|
<td><?php echo htmlentities($structure->headers['from']);?></td>
|
2018-07-28 07:21:43 +00:00
|
|
|
<td><?php echo htmlentities($structure->headers['x-original-to']);?></td>
|
|
|
|
<td><?php echo htmlentities($structure->headers['subject']);?></td>
|
2022-01-30 13:27:08 +00:00
|
|
|
<td><a href="/mail.php?delete=<?php echo $data['num']-1;?>" title="Delete Email"><i class="fa fa-trash"></i></a></td>
|
2016-10-30 13:40:29 +00:00
|
|
|
</tr>
|
|
|
|
<tr></tr>
|
2016-11-05 01:57:10 +00:00
|
|
|
<tr id="mail-<?php echo $data['num'];?>" style="display:none">
|
2016-10-30 13:40:29 +00:00
|
|
|
<td></td>
|
2022-01-30 13:27:08 +00:00
|
|
|
<td colspan="5">
|
2021-02-21 13:40:16 +00:00
|
|
|
<?php if ($body !== null): ?>
|
2021-11-07 13:56:54 +00:00
|
|
|
<template id="mail-body-<?=$data['num']?>"><?=$body?></template>
|
|
|
|
<html-email data-template-id="mail-body-<?=$data['num']?>"></html-email>
|
2017-12-08 15:17:07 +00:00
|
|
|
<?php else: ?>
|
2021-02-21 13:40:16 +00:00
|
|
|
<div class="alert alert-warning" role="alert">
|
2017-12-08 15:17:07 +00:00
|
|
|
No valid body found
|
2021-02-21 13:40:16 +00:00
|
|
|
</div>
|
2017-12-08 15:17:07 +00:00
|
|
|
<?php endif; ?>
|
2017-12-06 04:04:33 +00:00
|
|
|
<hr>
|
|
|
|
<p><a class="btn btn-primary" data-toggle="collapse" href="#email-<?php echo $data['num'];?>" aria-expanded="false" aria-controls="email-<?php echo $data['num'];?>">Raw source</a></p>
|
|
|
|
<div class="collapse" id="email-<?php echo $data['num'];?>"><pre><?php echo $message;?></pre></div>
|
2016-10-30 13:40:29 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2016-11-05 01:57:10 +00:00
|
|
|
<?php endforeach; ?>
|
2016-10-30 13:40:29 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2016-11-05 01:57:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-30 13:40:29 +00:00
|
|
|
</div><!-- /.container -->
|
|
|
|
|
2017-05-15 06:56:17 +00:00
|
|
|
<?php echo loadClass('Html')->getFooter(); ?>
|
2016-10-30 13:40:29 +00:00
|
|
|
<script>
|
|
|
|
$(function() {
|
2021-11-07 13:56:54 +00:00
|
|
|
$('.subject').click(function() {
|
|
|
|
var id = ($(this).attr('id'));
|
|
|
|
$('#mail-'+id).toggle();
|
2016-10-30 13:40:29 +00:00
|
|
|
})
|
|
|
|
// Handler for .ready() called.
|
|
|
|
});
|
|
|
|
</script>
|
2021-02-21 13:40:16 +00:00
|
|
|
<script src="/assets/js/html-email.js"></script>
|
2016-10-30 13:40:29 +00:00
|
|
|
</body>
|
|
|
|
</html>
|