I'd like to emit my own message when someone connects to this smtp server.
import smtpd
import asyncore
class FakeSMTPServer(smtpd.SMTPServer):
__version__ = 'TEST EMAIL SERVER'
def process_message(self, peer, mailfrom, rcpttos, data):
print 'Receiving message from:', peer
print 'Message addressed from:', mailfrom
print 'Message addressed to :', rcpttos
print 'Message length :', len(data)
return
if __name__ == "__main__":
smtp_server = FakeSMTPServer(('localhost', 25), None)
try:
asyncore.loop()
except KeyboardInterrupt:
smtp_server.close()
However, I am still getting the response:
220 Win7-PC Python SMTP proxy version 0.2
How do I override the welcome message in python to see "TEST EMAIL SERVER"?
Just do
somewhere (may be after import statements).