RSS Feed

Testing email logic in .Net with Papercut

Email is a great way to communicate something to the end user asynchronously. You can review the message anytime you want.  As Developers we often need to make some kind of logic which uses emails eg. reminders , alerts etc. While testing it is common to just send an email through smtp server. Receive it , check it etc.

But ?

What to do when you or your client doesn’t have an smtp server [or your admins doesn’t have time to configure it properly] ? Well there is a simple app which creates such a “testing server”

Papercut

 

Papercut is a simplified SMTP server designed to only receive messages (not to send them on) with a GUI on top of it allowing you to see the messages it receives. It doesn’t enforce any restrictions on addresses, it just takes the message and allows you see it. It is only active while it is running, and if you want it in the background, just minimize it to the system tray. When it receives a new message, a balloon message will show up to let you know.

 

Picture

Pic 1. Papercut Options Windows

Testing

Let’s test Papercut with a simple app.

 

static void Main(string[] args) { SmtpClient client = new SmtpClient("192.168.0.128",25); MailMessage msg = new MailMessage("michal.franc@mfranc.pl", "test@test.com",  

         "Testing mail", "Testing Body"); client.Send(msg); }

Papercut works in the background. When the message is received you get a nice popup, and you can check the message.

test

Pic 2. You can check the message.

As you can see it’s a great app which can be useful in many different scenarios.

Advertisements


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