added admin email account that can see all emails on all acounts
This commit is contained in:
parent
4811a8616a
commit
02d1a5977d
|
@ -28,6 +28,11 @@ if [ "$DOMAINS" != "" ]; then
|
||||||
echo " [i] Active Domain(s): $DOMAINS"
|
echo " [i] Active Domain(s): $DOMAINS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$ADMIN" != "" ]; then
|
||||||
|
echo "ADMIN=$ADMIN" >> /var/www/opentrashmail/config.ini
|
||||||
|
echo " [i] Set admin to: $ADMIN"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[MAILSERVER]" >> /var/www/opentrashmail/config.ini
|
echo "[MAILSERVER]" >> /var/www/opentrashmail/config.ini
|
||||||
echo "PORT=25" >> /var/www/opentrashmail/config.ini
|
echo "PORT=25" >> /var/www/opentrashmail/config.ini
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
; Enter your domains here. Comma separated if multiple
|
; Enter your domains here. Comma separated if multiple
|
||||||
DOMAINS=yourdomain,sub.yourdomain
|
DOMAINS=yourdomain,sub.yourdomain
|
||||||
|
|
||||||
|
; Enter the admin email address. If you choose this email on the website you will see all emails from all users
|
||||||
|
; The email doesn't really have to exist or have mail but must look like an email address
|
||||||
|
;ADMIN=some@random.email
|
||||||
|
|
||||||
[MAILSERVER]
|
[MAILSERVER]
|
||||||
; Port that the Mailserver will run on (default 25 but that needs root)
|
; Port that the Mailserver will run on (default 25 but that needs root)
|
||||||
MAILPORT=25
|
MAILPORT=25
|
28
web/api.php
28
web/api.php
|
@ -53,14 +53,38 @@ switch($action)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'list':
|
case 'list':
|
||||||
|
$settings = loadSettings();
|
||||||
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
|
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||||
$o = array('status'=>'err','reason'=>'Invalid Email address');
|
$o = array('status'=>'err','reason'=>'Invalid Email address');
|
||||||
|
else if($settings['ADMIN'] && $settings['ADMIN']==$email)
|
||||||
|
{
|
||||||
|
$o['status'] = 'ok';
|
||||||
|
$o['type'] = 'admin';
|
||||||
|
$emails = listEmailAdresses();
|
||||||
|
$emaillist = array();
|
||||||
|
|
||||||
|
if(count($emails))
|
||||||
|
{
|
||||||
|
foreach($emails as $email)
|
||||||
|
{
|
||||||
|
$emaildata = getEmailsOfEmail($email);
|
||||||
|
foreach($emaildata as $time=>$d)
|
||||||
|
{
|
||||||
|
$emaillist[$time.'-'.$email]=$d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(is_array($emaillist))
|
||||||
|
ksort($emaillist);
|
||||||
|
$data = (count($emaillist)?$emaillist:array());
|
||||||
|
}
|
||||||
|
|
||||||
|
$o['emails']=$data;
|
||||||
|
}
|
||||||
else if(!is_dir(ROOT.DS.'..'.DS.'data'.DS.$email))
|
else if(!is_dir(ROOT.DS.'..'.DS.'data'.DS.$email))
|
||||||
$o = array('status'=>'ok','emails'=>[]);
|
$o = array('status'=>'ok','emails'=>[]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$data = getEmailsOfEmail($email);
|
$data = getEmailsOfEmail($email);
|
||||||
|
|
||||||
$lastid = $_REQUEST['lastid'];
|
$lastid = $_REQUEST['lastid'];
|
||||||
if($lastid && is_numeric($lastid))
|
if($lastid && is_numeric($lastid))
|
||||||
{
|
{
|
||||||
|
@ -72,7 +96,7 @@ switch($action)
|
||||||
$data = (is_array($emails)?$emails:array());
|
$data = (is_array($emails)?$emails:array());
|
||||||
}
|
}
|
||||||
|
|
||||||
$o = array('status'=>'ok','emails'=>$data);
|
$o = array('status'=>'ok','emails'=>$data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,21 @@ function getEmailsOfEmail($email)
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function listEmailAdresses()
|
||||||
|
{
|
||||||
|
$o = array();
|
||||||
|
$o = false;
|
||||||
|
if ($handle = opendir(ROOT.DS.'..'.DS.'data'.DS)) {
|
||||||
|
while (false !== ($entry = readdir($handle))) {
|
||||||
|
if(filter_var($entry, FILTER_VALIDATE_EMAIL))
|
||||||
|
$o[] = $entry;
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
function loadSettings()
|
function loadSettings()
|
||||||
{
|
{
|
||||||
if(file_exists(ROOT.DS.'..'.DS.'config.ini'))
|
if(file_exists(ROOT.DS.'..'.DS.'config.ini'))
|
||||||
|
|
|
@ -37,7 +37,7 @@ function renderEmail(email,id,data)
|
||||||
btns+='<a class="btn btn-primary" target="_blank" href="api.php?a=attachment&email='+email+'&id='+id+'&filename='+filename+'" role="button">'+filename+'</a>'
|
btns+='<a class="btn btn-primary" target="_blank" href="api.php?a=attachment&email='+email+'&id='+id+'&filename='+filename+'" role="button">'+filename+'</a>'
|
||||||
}
|
}
|
||||||
$("#main").html('<h2 class="text-center">'+email+'</h2>\
|
$("#main").html('<h2 class="text-center">'+email+'</h2>\
|
||||||
<button onClick="loadAccount(\''+email+'\')" class="btn btn-primary my-2 my-sm-0"><i class="fas fa-backward"></i> Back</button>\
|
<button onClick="loadAccount(\''+activeemail+'\')" class="btn btn-primary my-2 my-sm-0"><i class="fas fa-backward"></i> Back</button>\
|
||||||
'+(data.parsed.body?'<pre>'+data.parsed.body+'</pre>':'')+' \
|
'+(data.parsed.body?'<pre>'+data.parsed.body+'</pre>':'')+' \
|
||||||
'+(data.parsed.htmlbody?'<div class="card card-body bg-light">'+data.parsed.htmlbody+'</pre>':'')+' \
|
'+(data.parsed.htmlbody?'<div class="card card-body bg-light">'+data.parsed.htmlbody+'</pre>':'')+' \
|
||||||
'+(btns!==''?'<h4>Attachments</h4>'+btns:'')+'\
|
'+(btns!==''?'<h4>Attachments</h4>'+btns:'')+'\
|
||||||
|
@ -56,7 +56,7 @@ function loadAccount(email)
|
||||||
<button onClick="loadAccount(\''+email+'\')" class="btn btn-success my-2 my-sm-0"><i class="fas fa-sync-alt"></i> Refresh</button>\
|
<button onClick="loadAccount(\''+email+'\')" class="btn btn-success my-2 my-sm-0"><i class="fas fa-sync-alt"></i> Refresh</button>\
|
||||||
<table class="table table-hover">\
|
<table class="table table-hover">\
|
||||||
<thead>\
|
<thead>\
|
||||||
<tr>\
|
<tr id="tableheader">\
|
||||||
<th scope="col">#</th>\
|
<th scope="col">#</th>\
|
||||||
<th scope="col">Date</th>\
|
<th scope="col">Date</th>\
|
||||||
<th scope="col">From</th>\
|
<th scope="col">From</th>\
|
||||||
|
@ -84,22 +84,36 @@ function updateEmailTable()
|
||||||
console.log("Checking mail for "+email)
|
console.log("Checking mail for "+email)
|
||||||
|
|
||||||
$.get("api.php?a=list&email="+email+"&lastid="+lastid,function(data){
|
$.get("api.php?a=list&email="+email+"&lastid="+lastid,function(data){
|
||||||
|
|
||||||
if(data.status=="ok")
|
if(data.status=="ok")
|
||||||
{
|
{
|
||||||
|
var admin=false;
|
||||||
|
if(data.type=="admin")
|
||||||
|
{
|
||||||
|
clearInterval(timer);
|
||||||
|
admin = true;
|
||||||
|
$('#tableheader').children(':eq(1)').after('<th scope="col">To</th>');
|
||||||
|
}
|
||||||
|
|
||||||
if(Object.keys(data.emails).length>0)
|
if(Object.keys(data.emails).length>0)
|
||||||
for(em in data.emails)
|
for(em in data.emails)
|
||||||
{
|
{
|
||||||
if($("#nomailyet").length != 0)
|
if($("#nomailyet").length != 0)
|
||||||
$("#nomailyet").remove();
|
$("#nomailyet").remove();
|
||||||
|
if(admin===true)
|
||||||
|
{
|
||||||
|
dateofemail=em.split("-")[0];
|
||||||
|
email = em.substring(em.indexOf('-') + 1);
|
||||||
|
}
|
||||||
|
else dateofemail = em;
|
||||||
if(em>lastid) lastid = em;
|
if(em>lastid) lastid = em;
|
||||||
var date = new Date(parseInt(em))
|
var date = new Date(parseInt(dateofemail))
|
||||||
var datestring = date.getDate()+"."+date.getMonth()+"."+date.getFullYear()+" "+date.getHours()+":"+date.getMinutes();
|
var datestring = date.getDate()+"."+date.getMonth()+"."+date.getFullYear()+" "+date.getHours()+":"+date.getMinutes();
|
||||||
var ed = data.emails[em]
|
var ed = data.emails[em]
|
||||||
$("#emailtable").append('\
|
$("#emailtable").append('\
|
||||||
<tr class="anemail" onClick="loadMail(\''+email+'\','+em+');">\
|
<tr class="anemail" onClick="loadMail(\''+email+'\','+dateofemail+');">\
|
||||||
<th scope="row">'+(index++)+'</th>\
|
<th scope="row">'+(index++)+'</th>\
|
||||||
<td >'+datestring+'</td>\
|
<td >'+datestring+'</td>\
|
||||||
|
'+(admin===true?'<td>'+email+'</td>':'')+'\
|
||||||
<td>'+ed.from.toHtmlEntities()+'</td>\
|
<td>'+ed.from.toHtmlEntities()+'</td>\
|
||||||
<td>'+ed.subject.toHtmlEntities()+'</td>\
|
<td>'+ed.subject.toHtmlEntities()+'</td>\
|
||||||
</tr>');
|
</tr>');
|
||||||
|
|
Loading…
Reference in a new issue