Set up Papercut SMTP with the Aspire integration

이 콘텐츠는 아직 번역되지 않았습니다.

⭐ Community Toolkit Papercut SMTP logo

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.

Aspire CLI — CommunityToolkit.Aspire.Hosting.PapercutSmtp 패키지 추가
aspire add communitytoolkit-papercutsmtp

Aspire CLI는 대화형입니다. 프롬프트 시 알맞은 검색 결과 선택:

Aspire CLI — 출력 예시
Select an integration to add:
> communitytoolkit-papercutsmtp (CommunityToolkit.Aspire.Hosting.PapercutSmtp)
> Other results listed as selectable options...

The optional httpPort and smtpPort arguments pin the host ports for the web console and SMTP listener. If omitted, Aspire assigns ports.

apphost.mts
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();

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.

MethodPurpose
AddPapercutSmtp / addPapercutSmtpAdd Papercut SMTP and optionally pin its HTTP and SMTP host ports.