Useful Tool of the Day: smtp4dev

We send a lot of emails to our users at Cheezburger. Sign up for an account, get a new user email. Submit some funny content, get a message with a link to the content so you can find it. Make the homepage and get a congratulatory message. You get the idea. As you can image our marketing team loves to wordsmith and prettify these messages. So we update them often.

I primarily work out of a Virtual Machine and try to keep running background tasks to a minimum. So, I don't particularly want a SMTP server running unless I am actively working on email code. Enter smtp4dev, a simple light weight dummy SMTP server. It runs in your system tray and gives you an easy way to capture email messages and view them.

So some simple code like this

using System.Net.Mail;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var message = new MailMessage("dirk@diggler.com", "jack@horner.com")
                {
                    Subject = "I AM THE STAR!",
                    Body = @"You're not the boss of me, Jack. You're not the king
                            of Dirk. I'm the boss of me. I'm the king of me. I'm 
                            Dirk Diggler. I'm the star."
                };

            new SmtpClient("localhost", 25)
                .Send(message);

        }
    }
}

smtp4dev will capture it like this:

MvFABVU

You can simply double click the message and open the EML file in your default email application to view it.

Follow me on Mastodon!