SmtpPilot is a mock SMTP server which allows developers to code e-mail functions and applications without the fear of sending to real addresses. SmtpPilot can run standalone as a server or in-process (if you are developing a .NET application). The goal of SmtpPilot is to comply with a substantial portion of RFC 5321 (as much as makes sense for a mock server) for the purposes of processing e-mail.
Setting up a basic server is as simple as running a few lines of code in your console application.
var server = new SMTPServer("127.0.0.1", 25);
server.Start();
Accessing into additional features requires initializing a configuration object and passing it to the server's constructor.
var config = new SmtpPilotConfiguration("127.0.0.1", 25);
var server = new SMTPServer(config);
server.Start();
Hooking into the built-in events requires adding a delegate to the server object.
var server = new SMTPServer("127.0.0.1", 25);
server.EmailProcessed += (s, evt) => Console.WriteLine("New Email from {0}", evt.Message.FromAddress);
server.Start();
Note: Adding new event delegates after the server has started is considered thread-safe.
Event Name | Arguments | Purpose |
---|---|---|
ClientConnected | object sender , MailClientConnectedEventArgs eventArgs |
Called whenever a new client has connected to the server. |
ClientDisconnected | object sender , MailClientDisconnectedEventArgs eventArgs |
Called whenever a client has disconnected from the server. |
EmailProcessed | object sender , EmailProcessedEventArgs eventArgs |
Called whenever an email send conversation has been completed. |