I saw this today on djangosnippets and figured it’s useful enough for me to post! Sometimes when writing a webapp you need to debug the output of your e-mail sending. This can be quite hard as things have to, usually, go via an SMTP server. What you really want is a quick way to grab the output with all the headers that YOUR code is setting - you can, easily, with Python.
OSX/Unix/Linux
sudo /usr/lib/python2.5/smtpd.py \
-n -c DebuggingServer localhost:25
(obviously on Solaris/OpenSolaris you want to use pfexec instead of sudo!)
Windows
c:\python25\python.exe c:\python25\lib\smtpd.py \
-n -c DebuggingServer localhost:25
You then get an output in the terminal window you ran it in every time a message hits the server. Handy.