Created
May 25, 2021 06:00
-
-
Save LuRsT/1f61b43b3f8105ae99444697d163ce4e to your computer and use it in GitHub Desktop.
SMTP Echo Server (a smtp server to run locally, prints out the emails as they arrive)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import asyncore | |
from email import message_from_string | |
from smtpd import DebuggingServer | |
class PrettyDebugginServer(DebuggingServer): | |
def process_message(self, peer, mailfrom, rcpttos, data): | |
print '---------- MESSAGE FOLLOWS ----------' | |
message = message_from_string(data) | |
print message.as_string().replace('=\n', '') | |
print '------------ END MESSAGE ------------' | |
if __name__ == '__main__': | |
server = PrettyDebugginServer( | |
('localhost', 1025), | |
('localhost', 8025), | |
) | |
try: | |
asyncore.loop() | |
except KeyboardInterrupt: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment