make config mandatory for the mailserver to start

This commit is contained in:
Chris 2019-08-16 13:30:30 +02:00
parent 4d1bf34e3c
commit f84f30376d
2 changed files with 21 additions and 2 deletions

View file

@ -1,2 +1,9 @@
; RENAME THIS FILE TO config.ini FIRST
[GENERAL]
; Enter your domains here. Comma separated if multiple
DOMAINS=yourdomain,sub.yourdomain
DOMAINS=yourdomain,sub.yourdomain
[MAILSERVER]
; Port that the Mailserver will run on (default 25 but that needs root)
MAILPORT=25

View file

@ -5,6 +5,7 @@ import email
from email.header import decode_header
from email.Utils import parseaddr
#import requests
import ConfigParser
import time
import os, sys
import json
@ -117,5 +118,16 @@ if __name__ == '__main__':
logger.setLevel(logging.DEBUG)
logger.addHandler(ch)
server = CustomSMTPServer(('0.0.0.0', 2525), None) # use your public IP here
if not os.path.isfile("../config.ini"):
print "[ERR] Config.ini not found. Rename example.config.ini to config.ini before starting the server :)"
sys.exit()
Config = ConfigParser.ConfigParser()
Config.read("../config.ini")
print "[i] Starting Mailserver on port",int(Config.get("MAILSERVER","PORT"))
server = CustomSMTPServer(('0.0.0.0', int(Config.get("MAILSERVER","PORT"))), None) # use your public IP here
print "[i] Ready to receive Emails"
print ""
asyncore.loop()