HmxLabs.SmtpUnit 0.1.0

.NET Framework 4.5
Install-Package HmxLabs.SmtpUnit -Version 0.1.0
dotnet add package HmxLabs.SmtpUnit --version 0.1.0
<PackageReference Include="HmxLabs.SmtpUnit" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HmxLabs.SmtpUnit --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: HmxLabs.SmtpUnit, 0.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install HmxLabs.SmtpUnit as a Cake Addin
#addin nuget:?package=HmxLabs.SmtpUnit&version=0.1.0

// Install HmxLabs.SmtpUnit as a Cake Tool
#tool nuget:?package=HmxLabs.SmtpUnit&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


SMTP Unit was written to help facilitate the testing of code that sends email without needing to use a real SMTP server to validate what was sent.

Now of course in your own code you have well defined interfaces and your test code has mocks (of those interfaces) and you don’t need a real SMTP server. Sometime though you need to use a library that doesn’t provide you the ability to do that, or maybe some legacy code, or maybe you just want to integration test your system with something as close to a production configuration as possible. This is meant to help out in all those cases.

It is written as additional constraints to NUnit and as such the idea is to allow you to write test code such as the following:

Assert.That(smtpServer, Received.Mail(1).From(""));
Assert.That(smtpServer, Received.Mail(1).Subject("Welcome to SMTPUnit"));
Assert.That(smtpServer, Received.Mail(1).BodyContains("Aren't automated test so great!"));


See documentation for further details but it is as simple as:

// Setup
var mockServer = new DummySmtpServer();

// Act – call your code to send email here

// Assert
Assert.That(mockServer, Received.Mail(1).From(""));


Since it is written as an NUnit constraint, there is a dependency on NUnit. There are no other dependencies if you wish to use SMTPUnit.

The test code for SMTPUnit however also has an additional dependency on HMX Core. This is not needed unless you wish to develop/contribute to SMTPUnit.


Much of the code is documented inline and the XML documentation files are included as part of the downloads. We are looking into hosting MSDN style documentation online but this is not yet available.

An example project is included in the source code also.


All versions are available either packaged as a NuGet package from NuGet or as a zip artefact from the HMx Labs website


HMx Labs Core is Open Source software and is licensed under an MIT style license. This allows use in both free and commercial applications without restriction. The complete licence text is available on the HMx Labs website or here

Contributing, Bug Reports and Support

If you’ve found a bug or thought of a new feature that would be useful feel free to either implement it and raise a pull request for us or if you’d like us to take a look then just get in touch.

Support is provided very much on a best effort only basis and by electronic means (emails, pull requests, bug reports etc) only.

Unless you’re a client of HMx Labs of course, in which case just give us a call!

Product Versions
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
    • NUnit (>= 2.6.4 && < 3.0.0)

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0 567 9/13/2018