Set up Papercut SMTP with the Aspire integration
이 콘텐츠는 아직 번역되지 않았습니다.
Use this hosting integration to run Papercut SMTP as a container resource for local email testing. For an introduction, see Get started with Papercut SMTP integration.
Installation
Section titled “Installation”aspire add communitytoolkit-papercutsmtpAspire CLI는 대화형입니다. 프롬프트 시 알맞은 검색 결과 선택:
Select an integration to add:
> communitytoolkit-papercutsmtp (CommunityToolkit.Aspire.Hosting.PapercutSmtp)> Other results listed as selectable options...#:package CommunityToolkit.Aspire.Hosting.PapercutSmtp@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.PapercutSmtp" Version="*" />Add a Papercut SMTP resource
Section titled “Add a Papercut SMTP resource”The optional httpPort and smtpPort arguments pin the host ports for the web console and SMTP listener. If omitted, Aspire assigns ports.
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();const papercut = await builder.addPapercutSmtp('papercut', { httpPort: 8080, smtpPort: 2525,});
const mailer = await builder.addProject('mailer', '../Mailer/Mailer.csproj');await mailer.withReference(papercut);await mailer.waitFor(papercut);
await builder.build().run();var builder = DistributedApplication.CreateBuilder(args);var papercut = builder.AddPapercutSmtp("papercut", httpPort: 8080, smtpPort: 2525);
builder.AddProject<Projects.Mailer>("mailer") .WithReference(papercut) .WaitFor(papercut);
// After adding all resources, run the app...builder.Build().Run();The resource provides an SMTP connection string in the form Endpoint=smtp://host:port. Referencing applications receive the connection under the resource name, such as ConnectionStrings:papercut in .NET configuration. Configure your SMTP library with the host and port from that endpoint. Papercut’s web console is available through the resource’s HTTP endpoint in the Aspire dashboard.
The integration does not provide an email client library. Use an SMTP library in the consuming app, and use WaitFor when the app must wait for Papercut to be ready before starting.
AppHost API
Section titled “AppHost API”| Method | Purpose |
|---|---|
AddPapercutSmtp / addPapercutSmtp | Add Papercut SMTP and optionally pin its HTTP and SMTP host ports. |