@brilab-mailer/provider-smtp
v0.0.2-12
Published
Generic SMTP provider that supports any SMTP-compatible service: - Gmail - Outlook - SendGrid SMTP - Mailgun SMTP - Custom SMTP servers
Readme
@brilab-mailer/provider-smtp
Overview
Generic SMTP provider that supports any SMTP-compatible service:
- Gmail
- Outlook
- SendGrid SMTP
- Mailgun SMTP
- Custom SMTP servers
Environment Variables
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=example
SMTP_PASS=password
[email protected]Installation
pnpm add @brilab-mailer/provider-smtp nodemailerProvider Implementation Summary
The SMTP provider:
- creates a nodemailer transport
- validates credentials
- sends messages via SMTP protocol
Usage in Core
MailerModule.register({
providerClass: MailerSmtpProvider,
templateEngineClass: HandlebarsTemplateEngine,
});Example Email
await this.mailer.send({
to: '[email protected]',
subject: 'Order Confirmation',
html: await this.mailer.render('order', { id: 123 }),
});Security Recommendations
- ALWAYS rotate SMTP passwords
- Use app passwords where possible
- Disable insecure ports (25)
- Use encrypted SMTP (TLS)
Troubleshooting
| Error | Meaning | Fix |
|------|---------|-----|
| ECONNREFUSED | Cannot connect | wrong host/port |
| EAUTH | Auth failed | wrong credentials |
| ETIMEDOUT | Firewall blocks connection | allow outbound 587 |
