How to Configure Windows Sandbox Local Mailpit SMTP Testing Server via XML in Windows 11

Testing transactional email delivery, password reset notifications, and HTML email templates is a standard requirement for web application developers. However, running local SMTP capture daemons directly on a workstation can cause port 1025/8025 conflicts and clutter local storage with test message databases. In Windows 11, Windows Sandbox provides a pristine, isolated testing platform. By authoring custom Windows Sandbox XML (.wsb) configuration files, you can deploy a standalone Mailpit SMTP testing server and web UI in seconds.

Architecture of the Disposable Mailpit Sandbox

Windows Sandbox provides a disposable, hypervisor-isolated guest environment that resets completely upon termination. To provision an automated Mailpit instance, the architecture requires:

  • A mapped host folder: A directory containing the standalone mailpit.exe binary and initial startup flags.
  • A WSB configuration file: An XML blueprint that mounts the mapped directory and initiates the SMTP agent automatically via LogonCommand.

Authoring the Windows Sandbox WSB Blueprint

Create a working directory on your host machine, such as C:\SandboxMailpit. Download the Windows binary of Mailpit into this directory, then create RunMailpit.wsb with the following XML code:

<Configuration>
  <VGpu>Default</VGpu>
  <Networking>Default</Networking>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\SandboxMailpit</HostFolder>
      <SandboxFolder>C:\MailpitFiles</SandboxFolder>
      <ReadOnly>false</ReadOnly>
    </MappedFolder>
  </MappedFolders>
  <LogonCommand>
    <Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File C:\MailpitFiles\Start-Mailpit.ps1</Command>
  </LogonCommand>
</Configuration>

Authoring Mailpit Startup Script

Inside the mapped host folder (C:\SandboxMailpit), create the PowerShell initialization script named Start-Mailpit.ps1:

Write-Host "=============================================" -ForegroundColor Cyan
Write-Host " Starting Mailpit SMTP Server in Sandbox...  " -ForegroundColor Green
Write-Host " Web UI:   http://127.0.0.1:8025             " -ForegroundColor Yellow
Write-Host " SMTP Port: 127.0.0.1:1025                   " -ForegroundColor Yellow
Write-Host "=============================================" -ForegroundColor Cyan

# Launch Mailpit with in-memory database storage
& "C:\MailpitFiles\mailpit.exe" --listen "0.0.0.0:8025" --smtp "0.0.0.0:1025" --database ""

Running and Validating Emails in the Sandbox

Double-click RunMailpit.wsb on your Windows 11 host. Windows Sandbox boots up, mounts the mapped folder, and immediately launches Mailpit inside an interactive PowerShell window.

The SMTP listener binds to port 1025, and the web inspection UI binds to port 8025. Open Microsoft Edge inside the sandbox and navigate to http://127.0.0.1:8025 to view the Mailpit inbox interface.

Configure local web applications or PowerShell test scripts to dispatch test emails to 127.0.0.1:1025. Inspect HTML email rendering, spam score evaluations, and attachment delivery in total isolation. When testing concludes, closing the sandbox window instantly eliminates all message databases, process threads, and network bindings, leaving your host workstation completely clean.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.