Skip to content
Fake SMTP server for developers - Catches emails sent via SMTP an puts them in a temp directory so you don't send people emails by accident
C# TypeScript CSS PowerShell Other
Branch: master
Clone or download
Latest commit b2620b7 Dec 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.deploy
SMTP.Impostor.Packager
SMTP.Impostor.Stores.FileSystem
SMTP.Impostor.Stores.InMemory
SMTP.Impostor.Test.Sender
SMTP.Impostor.Test
SMTP.Impostor.Worker
SMTP.Impostor
.dockerignore
.editorconfig
.gitignore
README.md
package-lock.json
smtp-impostor.sln
ui-screenshot.png

README.md

SMTP Impostor Icon

smtp-impostor v3.0

Fake SMTP server for developers - Catches emails sent via SMTP an puts them in a temp directory so you don't send people emails by accident

in development, but works now

worker written in c# dotnet core 3, the ui (wip) will need npm to build

available scripts /.deploy

  1. /.deploy/build.ps1 builds worker project and publishes to /dist.
    • Run the SMTP.Impostor.Worker.exe to run as a console
  2. /.deploy/install.ps1 builds and installs as windows service
    • requires admin elevation and request user to run service as
  3. /.deploy/uninstall.ps1 uninstalls the installed service
    • requires admin elevation

{id}.eml files are dropped in {Drive}\Users\{User}\AppData\Local\Temp\Impostor\127.0.0.1_25, windows 10 mail app can open them, otherwise you will need thunderbird or outlook desktop

once running the admin ui (wip) is available through a browser https://localhost:62525, you can install it as a web app if you are using a browser that supports progressive web apps (pwa)

SMTP Impostor UI

using in unit tests

[TestMethod]
public void catch_emails_with_impostor()

  var hostSettings = new SMTPImpostorHostSettings(
            ip: "127.0.0.1",
            port: 52525);

  SMTPImpostorMessage messages = null;

  using var host = GetSMTPImpostorHost(hostSettings);
  using var events = host.Events
          .OfType<SMTPImpostorMessageReceivedEvent>()
          .Subscribe(e => message = e.Data);

  using var client = new SmtpClient(hostSettings.HostName, hostSettings.Port);
  using var mailMessage = new MailMessage
  {
      From = new MailAddress("a@example.com"),
      Subject = "SUBJECT",
      Body = "SOME CONTENT\nSOME CONTENT\nSOME CONTENT\nSOME CONTENT\n"
  };
  mailMessage.To.Add("b@example.com");

  client.Send(mailMessage);

  Assert.IsFalse(string.IsNullOrWhiteSpace(message.Id));
  Assert.AreNotEqual(0, message.Headers);
  Assert.IsFalse(string.IsNullOrWhiteSpace(message.Subject));
}

ISMTPImpostorHost GetSMTPImpostorHost(
    SMTPImpostorHostSettings hostSettings)
{
    var services = new ServiceCollection()
        .AddLogging()
        .AddSMTPImpostor()
        .AddSMTPImpostorInMemoryMessagesStore()
        .BuildServiceProvider();

    var hostProvider = services.GetRequiredService<ISMTPImpostorHostProvider>();
    var host = hostProvider.CreateHost(hostSettings);
    host.Start();

    return host;
}
You can’t perform that action at this time.