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.