Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Integration testing against e-mail almost always sucks. EmbeddedMail doesn't remove all of that pain, but it certainly helps it suck less by providing an in-memory SMTP server that you can assert on.
branch: master
Failed to load latest commit information.
buildsupport @ 15b7399 Converted to ripple2
packaging/nuget Some nuspec tweaks
src More exception cleanup
.gitignore Ignores the DotSettings file
.gitmodules
TESTS.txt Initial commit
VERSION.txt CI fixes. Bumping the version
license.txt Adds support for attachments, cleans up the message parsing, adds readme
rakefile.rb Upgrading the rake to the latest. Removing the autopublish
readme.md Fix typo in Em[b]eddedSmtpServer
ripple.cmd 'seeding'
ripple.config Converted to ripple2

readme.md

EmbeddedMail

Overview

Integration testing against e-mail almost always sucks. EmbeddedMail doesn't remove all of that pain, but it certainly helps it suck less. It's just a simple class library with 0 dependencies.

Show me the code

Here's some simple example code:

var server = new EmbeddedSmtpServer(8181);
server.Start();

var message = new MailMessage("x@domain.com", "y@domain.com", "Hello there", "O hai");
using(var client = new SmtpClient("localhost", 8181))
{
    client.Send(message);
}

server.Stop();

var received = server.ReceivedMessages().First();

received.Body.ShouldEqual(message.Body);
received.Subject.ShouldEqual(message.Subject);

How it works

The idea is that you collapse your app-domain for integration-testing purposes by embedding an SMTP server inside of your tests. You then run some code that would shoot out emails, stop the smtp server, and make assertions on the messages that were received (e.g., "The body should be...")

NuGet

Install-Package EmbeddedMail

Shout outs

I took a look at some of the existing solutions out there and found two:

  • netDumpster
  • nDumpster

Some of the message parsing "borrows" some code found in netDumpster (thanks Carlos and Eric for your contributions -- your work is cited).

Also, I borrowed some socket/logging code from Jason Staten and his excellent Fleck library.

Something went wrong with that request. Please try again.