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
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.deploy add test sender to the dist folder, moved worker to sub folder Oct 28, 2019
.github/workflows Update dotnetcore.yml Dec 15, 2019
SMTP.Impostor.Packager
SMTP.Impostor.Stores.FileSystem fix(worker): reduce debounce on settings save, too long may mean its … Dec 13, 2019
SMTP.Impostor.Stores.InMemory
SMTP.Impostor.Test.Sender fix(package): more icons Jan 4, 2020
SMTP.Impostor.Test wip(ui): allow stop of the worker service from ui Dec 1, 2019
SMTP.Impostor.Worker fix(package): more icons Jan 4, 2020
SMTP.Impostor
.dockerignore
.editorconfig
.gitignore fix(package): more icons Jan 4, 2020
README.md docs(ui): animated png Dec 14, 2019
package-lock.json refactor(deploy): update powershell scripts to be more modular Oct 14, 2019
smtp-impostor.sln
ui-screenshot.png docs(ui): smaller image Dec 14, 2019
ui-video.mp4
ui-video.png docs(ui): video bit bigger Dec 14, 2019

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

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.