From f84f30376d3dc2d90c009cfad62ab632f3dfc395 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 16 Aug 2019 13:30:30 +0200 Subject: [PATCH] make config mandatory for the mailserver to start --- example.config.ini | 9 ++++++++- python/mailserver.py | 14 +++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/example.config.ini b/example.config.ini index 2ceda72..c179743 100644 --- a/example.config.ini +++ b/example.config.ini @@ -1,2 +1,9 @@ +; RENAME THIS FILE TO config.ini FIRST + +[GENERAL] ; Enter your domains here. Comma separated if multiple -DOMAINS=yourdomain,sub.yourdomain \ No newline at end of file +DOMAINS=yourdomain,sub.yourdomain + +[MAILSERVER] +; Port that the Mailserver will run on (default 25 but that needs root) +MAILPORT=25 \ No newline at end of file diff --git a/python/mailserver.py b/python/mailserver.py index ba4e6b4..43bc026 100644 --- a/python/mailserver.py +++ b/python/mailserver.py @@ -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() \ No newline at end of file