MVFC.Aspire.Helpers.Mailpit 8.0.1

dotnet add package MVFC.Aspire.Helpers.Mailpit --version 8.0.1
                    
NuGet\Install-Package MVFC.Aspire.Helpers.Mailpit -Version 8.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MVFC.Aspire.Helpers.Mailpit" Version="8.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MVFC.Aspire.Helpers.Mailpit" Version="8.0.1" />
                    
Directory.Packages.props
<PackageReference Include="MVFC.Aspire.Helpers.Mailpit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MVFC.Aspire.Helpers.Mailpit --version 8.0.1
                    
#r "nuget: MVFC.Aspire.Helpers.Mailpit, 8.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MVFC.Aspire.Helpers.Mailpit@8.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MVFC.Aspire.Helpers.Mailpit&version=8.0.1
                    
Install as a Cake Addin
#tool nuget:?package=MVFC.Aspire.Helpers.Mailpit&version=8.0.1
                    
Install as a Cake Tool

MVFC.Aspire.Helpers.Mailpit

🇧🇷 Leia em Português

CI codecov License Platform NuGet Version NuGet Downloads

Helpers for integrating with the MailPit SMTP emulator in .NET Aspire projects, easing the testing of email delivery in development environments.

Motivation

Testing e‑mail locally often means:

  • Pointing your app to a real SMTP server or a fragile test server.
  • No safe way to inspect messages without actually sending them.
  • Manual setup of Mailpit/Mailhog containers per project.

With .NET Aspire you can define the container, but you still need to:

  • Configure SMTP and web ports.
  • Decide where to persist Mailpit data.
  • Wire your applications to the SMTP host/port.

MVFC.Aspire.Helpers.Mailpit offers:

  • AddMailpit(...) to provision the SMTP emulator.
  • Fluent options for max messages, authentication, data file path and logging.
  • WithReference(...) to connect projects to Mailpit.

Overview

This project allows adding and integrating MailPit as a managed resource in distributed .NET Aspire applications. It simplifies provisioning the MailPit container, exposes the web interface to view received emails, and provides extension methods for AppHost configuration.

Project Structure

Features

  • Adds the MailPit container to the Aspire application.
  • Exposes the web interface for visualizing received emails.
  • Extension methods to facilitate AppHost configuration.
  • Allows configuration of port, maximum number of messages, authentication, and optional data persistence.

Compatible Images

  • axllent/mailpit

Installation

dotnet add package MVFC.Aspire.Helpers.Mailpit

Quick Aspire usage (AppHost)

using Aspire.Hosting;
using MVFC.Aspire.Helpers.Mailpit;

var builder = DistributedApplication.CreateBuilder(args);

var mailpit = builder.AddMailpit("mailpit")
    .WithMaxMessages(1000)
    .WithDataFilePath("/data/mailpit.db")
    .WithWebAuth(username: "admin", password: "secret");

builder.AddProject<Projects.MVFC_Aspire_Helpers_Playground_Api>("api-example")
       .WithReference(mailpit)
       .WaitFor(mailpit);

await builder.Build().RunAsync();

Provisioning diagram

sequenceDiagram
    participant Aspire as .NET Aspire
    participant Container as Mailpit Container
    
    Aspire->>Container: Start container (axllent/mailpit)
    Container-->>Aspire: Ready (SMTP and UI ports available)
    Aspire->>App: Start App with SMTP ConnectionString

Fluent methods

Method Description
WithDockerImage(image, tag) Overrides the Docker image used.
WithMaxMessages(max) Defines the maximum number of stored messages.
WithMaxMessageSize(sizeInMb) Defines the maximum size of each message in MB.
WithSmtpAuth() Enables SMTP authentication (accept any + insecure).
WithSmtpHostname(hostname) Defines the SMTP server hostname.
WithDataFilePath(path) Defines the file path for email persistence.
WithWebAuth(username, password) Enables authentication on the web interface.
WithVerboseLogging() Enables verbose MailPit logs.

AddMailpit parameters

Parameter Type Default Description
name string Resource name.
httpPort int 8025 Web interface port.
smtpPort int 1025 SMTP server port.

Ports and visualization

  • SMTP port: smtpPort (default 1025).
  • Web port: httpPort (default 8025).
  • Web UI: http://localhost:<httpPort>/.

Requirements

  • .NET 9+
  • Aspire.Hosting >= 9.5.0

License

Apache-2.0

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.1 39 4/3/2026
8.0.0 70 4/2/2026
7.3.3 84 3/31/2026
7.3.2 80 3/30/2026
7.3.1 82 3/30/2026
7.3.0 83 3/30/2026
7.2.2 88 3/29/2026
7.2.1 80 3/29/2026
7.2.0 83 3/29/2026
7.1.0 80 3/22/2026
6.4.4 81 3/21/2026
6.4.3 86 3/15/2026
6.4.2 85 3/15/2026
6.4.1 84 3/10/2026
6.4.0 82 3/9/2026
6.3.0 88 3/8/2026
6.2.0 80 3/8/2026
6.1.1 81 3/7/2026
6.0.0 80 3/7/2026
5.1.0 90 2/28/2026
Loading failed