Setting up a simple smtp server for testing
On many websites, there is a need for sending mail from the webserver. While testing, it’s sometimes painful to get a working smtp server to test this.
I’ve used this script for a while now, since it’s the simplest way to get a mailserver running. It will accept any smtp connection and print the mail to the terminal where you started it from.
1import smtpd, asyncore 2 3print 'Mailserver is on port 8025. Press ctrl-c to stop.' 4server = smtpd.DebuggingServer(('localhost', 8025), None) 5asyncore.loop()
Place those four lines into a python file (I used dummymailserver.py) and then run the python file:
And you’re done!