#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @Contact : liuyuqi.gov@msn.cn @Time : 2023/01/30 09:47:22 @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved. @Desc : enter point ''' from receive_email.smtpx import CrazySrvHandler from receive_email.web import web_start from aiosmtpd.controller import Controller from aiosmtpd.smtp import SMTP import configparser if __name__ == "__main__": cf = configparser.ConfigParser() cf.read("conf/cfg.ini") smtpd_host = cf.get("smtpd", "host") smtpd_port = cf.getint("smtpd", "port") rest_host = smtpd_host rest_port = cf.getint("rest", "port") handler = CrazySrvHandler() # 邮件控制器 controller = Controller(handler, hostname=smtpd_host, port=smtpd_port) controller.factory = lambda: SMTP(handler, enable_SMTPUTF8=True) try: controller.start() # 启动 flask web 接口,14000 端口 web_start(rest_host, rest_port) except KeyboardInterrupt: print("Shutting down") finally: controller.stop()