initial test

This commit is contained in:
Chris 2019-08-13 23:35:40 +02:00
parent 4f61600a95
commit 0428ecad50
3 changed files with 32 additions and 1 deletions

View File

@ -1,2 +1,7 @@
# opentrashmail
# Open Trashmail
Open source / selfhostable trashmail solution
# Features
- Python powered mail server that works out of the box for any domain
- Web interface to manage mails and credentials
- 100% file based, no database needed

2
data/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

24
python/mailserver.py Normal file
View File

@ -0,0 +1,24 @@
import smtpd
import asyncore
import uuid
import time
import os, sys
import json
class CustomSMTPServer(smtpd.SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
print 'Receiving message from:', peer
print 'Message addressed from:', mailfrom
print 'Message addressed to :', rcpttos
print 'Message length :', len(data)
print "----------"
for email in rcpttos:
if not os.path.exists("../data/"+email):
os.mkdir( "../data/"+email, 0755 )
with open("../data/"+email+"/"+str(int(round(time.time() * 1000)))+".json", "w") as outfile:
json.dump({'sender_ip':peer[0],'from':mailfrom,'rcpts':rcpttos,'data':data}, outfile)
return
server = CustomSMTPServer(('0.0.0.0', 25), None)
asyncore.loop()