Friday, March 27, 2009

DevSmtp server released

Have you ever debugged sending emails from your application? I have many times. Users of your website pay for goods and then they should be sent a notification. The conditions to test receiving mails can be uneasy. User account email should be valid and you are allowed to connect to smtp server or have your local smtp that might be considered by the remote one as unreliable and your mail will be rejected or cut off by a spam filter.

As a developer I always wanted a reliable tool for checking the both things: to ensure the email is sent and see how the email looks like for user.

Besides Windows Vista doesn't have an smtp server. So I decided to implement it on my own. It wasn't a real world project and I didn't have tight schedule, so I chose to refresh my C++ skills that had been more academical than practical and to write a server using I/O Completion Ports.

I use github to host the project. There you can either download the project source code and compile it in VS 2008 or get a precompiled binary.
  1. In order to run in console mode put devsmtp.exe in an appropriate location and execute: devsmtp -c
  2. to register as windows service, execute: devsmtp -i (to uninstall, use devsmtp -u)
Now start testing you programs. If you want to verify a message is sent, run DebugView utility and you will see smtp communication protocol messages between your application and the server. After the message is on the server, it will be stored in a folder under devsmtp.exe location named with from email.

So you can double click on the eml file and see it in embedded viewer.

Attention. The server doesn't send mails to recipients. It serves for the debugging purpose only.

Have fun!