Project Description
NFakeMail makes it easier for developers to do integration/system testing on software that sends emails by providing a fake SMTP server. You'll no longer have to manually validate the email sending process. It's developed in C# and IronPython and targets the .NET 4.0 framework.

Requirements
Installation
To install NFakeMail you just need to take the following steps:
  • Download the latest release;
  • Unzip it;
  • Set an IRONPYTHONPATH environment variable that points to the Python 2.6 Standard Library.

Getting Started
  • Using NFakeMail Library
Add a reference to NFakeMail.dll, IronPython.dll, IronPython.Modules.dll and then use it like in the following example:

private const int SmtpServerPort = 10025;

private static void Main(string[] args)
{
    using (var fakeSmtpServer = new FakeSmtpServer(SmtpServerPort))
    {
        InvokeCodeThatSendsEmail();

        // Verifies that two messages are received in the next five seconds
        var messages = fakeSmtpServer.WaitForMessages(count: 2, timeout: 5000);

        // Verifies the message sender
        Debug.Assert(messages.All(m => m.From.Address == "me@me.com"));
    }
}

private static void InvokeCodeThatSendsEmail()
{
    using (var smtpClient = new SmtpClient("localhost", SmtpServerPort))
    {
        smtpClient.Send("me@me.com", "you@you.com", "S1", ".");

        smtpClient.Send("me@me.com", "you@you.com", "S2", "..");
    }
}
  • Using NFakeMail Runner Console Application
USAGE:
     -port user_value [-silent -outputPath user_value]

  where
    -silent | -s
        Specifies if the application should not output information.
        Default: False

    -outputPath | -o
        Specifies the path where the mail messages will be stored.

    -port | -p
        Specifies the local port for the SMTP server to listen for requests.
        Default: 10025

Last edited Sep 9, 2010 at 12:16 AM by jmangelo, version 11