Mailpit Hosting integration reference
이 콘텐츠는 아직 번역되지 않았습니다.
To get started with the Aspire Mailpit integrations, follow the Get started with Mailpit integrations guide.
This article includes full details about the Aspire Mailpit Hosting integration.
Installation
Section titled “Installation”To access the Mailpit hosting integration APIs for expressing Mailpit resources in your AppHost project, install the 📦 CommunityToolkit.Aspire.Hosting.MailPit NuGet package:
aspire add communitytoolkit-mailpitAspire CLI는 대화형입니다. 프롬프트 시 알맞은 검색 결과 선택:
Select an integration to add:
> communitytoolkit-mailpit (CommunityToolkit.Aspire.Hosting.MailPit)> Other results listed as selectable options...#:package CommunityToolkit.Aspire.Hosting.MailPit@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.MailPit" Version="*" />Add Mailpit resource
Section titled “Add Mailpit resource”To add Mailpit to your app host, use the AddMailPit extension method:
var builder = DistributedApplication.CreateBuilder(args);
var mailpit = builder.AddMailPit("mailpit");
builder.AddProject<Projects.ExampleProject>() .WithReference(mailpit);
// After adding all resources, run the app...When Aspire adds Mailpit to the app host, it creates a new Mailpit instance with the docker.io/axllent/mailpit container image.
Mailpit exposes two ports:
- SMTP port: 1025 (for sending emails)
- Web UI port: 8025 (for viewing emails in the browser)
Both ports are automatically configured and accessible through the Aspire dashboard.
Data persistence
Section titled “Data persistence”To persist emails across container restarts, use the WithDataVolume method:
var builder = DistributedApplication.CreateBuilder(args);
var mailpit = builder.AddMailPit("mailpit") .WithDataVolume();
builder.AddProject<Projects.ExampleProject>() .WithReference(mailpit);The data volume is used to persist the Mailpit data outside the lifecycle of the container.
For development scenarios, you may want to use bind mounts instead of data volumes. To add a data bind mount, call the WithDataBindMount method:
var builder = DistributedApplication.CreateBuilder(args);
var mailpit = builder.AddMailPit("mailpit") .WithDataBindMount(source: @"C:\Mailpit\Data");
builder.AddProject<Projects.ExampleProject>() .WithReference(mailpit);Web UI
Section titled “Web UI”The Mailpit web interface is automatically available when you add a Mailpit resource. You can access it through the Aspire dashboard by clicking on the endpoint for the Mailpit resource.