Created
May 23, 2015 13:47
-
-
Save MarkusH/ad955fb094007cc9be24 to your computer and use it in GitHub Desktop.
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 python3 | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
from smtpd import SMTPServer | |
import asyncore | |
import quopri | |
class DebuggingServer(SMTPServer): | |
def process_message(self, peer, mailfrom, rcpttos, data): | |
inheaders = 1 | |
lines = data.split('\n') | |
print('---------- MESSAGE FOLLOWS ----------') | |
for line in lines: | |
if inheaders and not line: | |
print('X-Peer: %s' % peer[0]) | |
inheaders = 0 | |
if line.endswith('='): | |
print(quopri.decodestring(line[:-1]), end='') | |
else: | |
print(quopri.decodestring(line)) | |
print('------------ END MESSAGE ------------') | |
if __name__ == '__main__': | |
server = DebuggingServer(('127.0.0.1', 1025), None) | |
print('Listening on 127.0.0.1:1025') | |
asyncore.loop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment