Setting up a simple smtp server for testing

Share on:

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.

The script:

1import smtpd, asyncore
3print 'Mailserver is on port 8025. Press ctrl-c to stop.'
4server = smtpd.DebuggingServer(('localhost', 8025), None)

Place those four lines into a python file (I used and then run the python file:


And you’re done!