Skip to content

Instantly share code, notes, and snippets.

@LuRsT
Created May 25, 2021 06:00
Show Gist options
  • Save LuRsT/1f61b43b3f8105ae99444697d163ce4e to your computer and use it in GitHub Desktop.
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)
#!/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