Lee Packham’s Corner
The rants of a software busy body
  • Home
  • Gallery
  • About
  • dtrace Stuff

Debugging SMTP

Python Add comments

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.


September 9th, 2008 |

2 Responses to “Debugging SMTP”

  1. David Rickard
    September 9th, 2008 at 6:36 pm

    That’s insanely useful. I assume it can listen on other addresses, i.e. could sit there picking up mail from another host? Useful none the less :)


  2. Einars
    September 10th, 2008 at 2:10 am

    Extending the idea of sent mails debugging, quite a long time ago I wrote a little debugging script, which you can download at http://elfz.laacz.lv/fakemail.py — it’s much like your suggestion, only it acts as a POP3 server as well, so you can use your mail client to download sent messages and see how they came out. Maybe you could find it useful.


Leave a Reply

  • Friend's Blogs/Sites

    • David Rickard
    • Lloyd Pick
    • Michael Smith
  • Recent Posts

    • Is it any wonder the world is infested with spam?
    • The Wowhead Christmas Wallpaper
    • Unibody Macbook Pro constantly waking up
    • How Warcraft reigned supreme in 2008
    • CRY vs. DRY
  • Archives

    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • November 2007
    • October 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • January 2007
    • December 2006
    • October 2006
    • September 2006
  • Recent Tracks (last.fm)

    • Nickelback – Gotta Be Somebody 15 hours ago
    • Nickelback – Burn It to the Ground 15 hours ago
    • Nickelback – Something in Your Mouth 15 hours ago
    • Lisa Miskovsky – Still Alive (The Theme from Mirror's Edge) (Paul Van Dyk Mix) 15 hours ago
    • The Prodigy – Charly 19 hours ago
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
Copyright © 2009 Lee Packham’s Corner All Rights Reserved
RSS XHTML CSS Log in
Wp Theme by n Graphic Design
Powered by Wordpress