Created
September 20, 2019 18:23
-
-
Save carc1n0gen/c3b83b2abe6b1d613d0bbc392a894d40 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import smtpd | |
import asyncore | |
class FakeSMTPServer(smtpd.SMTPServer): | |
messages = [] | |
def __init__(*args, **kwargs): | |
print('Fake smtp server running on port 2525') | |
smtpd.SMTPServer.__init__(*args, **kwargs) | |
def process_message(self, peer, mailfrom, rcpttos, data, **kwargs): | |
self.messages.append(data) | |
if __name__ == '__main__': | |
smtp_server = FakeSMTPServer(('localhost', 2525), None) | |
try: | |
asyncore.loop() | |
except KeyboardInterrupt: | |
smtp_server.close() | |
print(smtp_server.messages) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment