getting things done

This commit is contained in:
Chris 2019-08-16 10:30:23 +02:00
parent 76ff34c8f0
commit be748aeef0
3 changed files with 68 additions and 35 deletions

View file

@ -29,16 +29,19 @@
- [x] Download attachments in a safe way - [x] Download attachments in a safe way
- [x] Display Text/HTML - [x] Display Text/HTML
- [x] API so all features from the site can also be automated and integrated - [x] API so all features from the site can also be automated and integrated
- [ ] Automatically check for new emails while on site - [x] Automatically check for new emails while on site
- [ ] Secure HTML so no malicious things can be loaded - [ ] Secure HTML so no malicious things can be loaded
- [ ] Display embedded images inline using Content-ID - [ ] Display embedded images inline using Content-ID
- [ ] Admin overview for all available email addresses - [ ] Admin overview for all available email addresses
- [ ] Delete messages - [ ] Delete messages
- [ ] Make better theme
- [ ] Configurable settings - [ ] Configurable settings
- [x] Choose domains for random generation - [x] Choose domains for random generation
- [ ] Choose if out-of-scope emails are discarded - [ ] Choose if out-of-scope emails are discarded
- [ ] Honeypot mode where all emails are also saved for a catchall account - [ ] Honeypot mode where all emails are also saved for a catchall account
- [ ] Docker files and config - [ ] Optionally secure whole site with a password
- [ ] Optinally allow site to be seen only from specific IP Range
- [ ] Docker files and configs
# Features # Features
- Python powered mail server that works out of the box for any domain - Python powered mail server that works out of the box for any domain

View file

@ -60,6 +60,18 @@ switch($action)
else else
{ {
$data = getEmailsOfEmail($email); $data = getEmailsOfEmail($email);
$lastid = $_REQUEST['lastid'];
if($lastid && is_numeric($lastid))
{
foreach($data as $time=>$d)
{
if($time>$lastid)
$emails[$time]=$d;
}
$data = (is_array($emails)?$emails:array());
}
$o = array('status'=>'ok','emails'=>$data); $o = array('status'=>'ok','emails'=>$data);
} }
break; break;

View file

@ -1,12 +1,17 @@
var domains = []; var domains = [];
var lastid = 0;
var activeemail = '';
var timer;
$( document ).ready(function() { $( document ).ready(function() {
$.ajaxSetup({ cache: false });
var email = window.location.hash.substr(1); var email = window.location.hash.substr(1);
if(validateEmail(email)) if(validateEmail(email))
loadAccount(email) loadAccount(email)
$.get("api.php?a=getdoms",function(data){ $.get("api.php?a=getdoms",function(data){
console.log(data)
domains = data; domains = data;
},"json") },"json")
}); });
@ -14,7 +19,7 @@ $( document ).ready(function() {
function loadMail(email,id) function loadMail(email,id)
{ {
$.get("api.php?a=load&email="+email+"&id="+id,function(data){ $.get("api.php?a=load&email="+email+"&id="+id,function(data){
//console.log(data); //
if(data.status=="ok") if(data.status=="ok")
{ {
renderEmail(email,id,data.data) renderEmail(email,id,data.data)
@ -24,16 +29,15 @@ function loadMail(email,id)
function renderEmail(email,id,data) function renderEmail(email,id,data)
{ {
console.log("rendering") clearInterval(timer);
console.log(data)
var btns = '' var btns = ''
for(att in data.parsed.attachments) for(att in data.parsed.attachments)
{ {
console.log(data.parsed.attachments[att])
var filename=data.parsed.attachments[att].substr(14) var filename=data.parsed.attachments[att].substr(14)
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>\
'+(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:'')+'\
@ -44,9 +48,12 @@ function loadAccount(email)
{ {
if(validateEmail(email)) if(validateEmail(email))
{ {
var index = 1; activeemail = email;
lastid = 0;
changeHash(email) changeHash(email)
$("#main").html('<h2 class="text-center">'+email+'</h2>\ $("#main").html('<h2 class="text-center">'+email+'</h2>\
<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>\
@ -61,13 +68,29 @@ function loadAccount(email)
</table>\ </table>\
') ')
$.get("api.php?a=list&email="+email,function(data){ timer = setInterval(updateEmailTable, 5000); //check for new mail every 5 seconds
console.log(data); updateEmailTable(); //and check now
}
else
{
changeHash("")
}
}
function updateEmailTable()
{
var email = activeemail;
var index = 1;
console.log("Checking mail for "+email)
$.get("api.php?a=list&email="+email+"&lastid="+lastid,function(data){
if(data.status=="ok") if(data.status=="ok")
{ {
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(em>lastid) lastid = em;
var date = new Date(parseInt(em)) var date = new Date(parseInt(em))
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]
@ -79,7 +102,7 @@ function loadAccount(email)
<td>'+ed.subject.toHtmlEntities()+'</td>\ <td>'+ed.subject.toHtmlEntities()+'</td>\
</tr>'); </tr>');
} }
else{ else if(lastid==0){
console.log("leider keine post") console.log("leider keine post")
$("#emailtable").append('\ $("#emailtable").append('\
<tr>\ <tr>\
@ -89,11 +112,6 @@ function loadAccount(email)
} }
},"json") },"json")
} }
else
{
changeHash("")
}
}
function accessAccount() function accessAccount()
{ {