From dfa776ddf9e6b84f9602a60a8637bd03c150b6c0 Mon Sep 17 00:00:00 2001 From: Yannik Schmidt Date: Sun, 9 Oct 2022 12:41:43 +0200 Subject: [PATCH] Initial --- server.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 server.py diff --git a/server.py b/server.py new file mode 100755 index 0000000..ed995d3 --- /dev/null +++ b/server.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 + +import aiosmtpd.controller +import email +import email.policy +#import aiosmtpd.smtp.AuthResult, aiosmtpd.smtp.LoginPassword + +USER = "test" +PASS = "test123" + + +class CustomSMTPHandler: + + async def handle_DATA(self, server, session, envelope): + mail = email.message_from_bytes(envelope.content, policy=email.policy.default) + print(mail.get("subject")) + print(mail.get_body()) + return '250 OK' + + async def handleAUTH(server, session, envelope, mechanism, auth_data): + username = auth_data.login + password = auth_data.password + print("Auth Callback") + if username == USER and password == PASS: + return '235 Authentication successful' + #return aiosmtpd.smtp.AuthResult(success=True) + else: + assert(False) + return 'None' + #return aiosmtpd.smtp.AuthResult(success=False) + +if __name__ == "__main__": + handler = CustomSMTPHandler() + server = aiosmtpd.controller.Controller(handler, hostname="0.0.0.0", port=8025) + server.start() + input("Server started. Press Return to quit.") + server.stop()