@brilab-mailer/provider-mailtrap
v0.0.2-12
Published
A production-ready Mailtrap email provider for Brilab Mailer. Supports both API and SMTP versions (API mode recommended).
Downloads
2,639
Readme
@brilab-mailer/provider-mailtrap
Overview
A production-ready Mailtrap email provider for Brilab Mailer.
Supports both API and SMTP versions (API mode recommended).
Configuration
Environment Variables
MAILTRAP_API_TOKEN=xxxx
MAILTRAP_INBOX_ID=12345
[email protected]Installation
pnpm add @brilab-mailer/provider-mailtrapUsage
MailerModule.register({
providerClass: MailtrapApiProvider,
templateEngineClass: HandlebarsTemplateEngine,
});Provider Implementation
@Injectable()
export class MailtrapApiProvider implements MailerProvider {
async send(options: MailerSendOptions) {
await this.client.send({
from: { email: this.sender },
to: [{ email: options.to }],
subject: options.subject,
html: options.html,
});
}
}Debugging
- Invalid token → 401
- Invalid inbox → 404
- Rate limit → auto-retry recommended in mailer-core
Best Practices
- Use per-environment inbox IDs
- Never store token in repository
- Use template engine instead of raw HTML
