I Am Not Myself

Bills.Pay(Developer.Skills).ShouldBeTrue()

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: