@cinnabun/mail
v0.0.13
Published
Email module for Cinnabun with SMTP and template rendering
Maintainers
Readme
@cinnabun/mail
Email module for Cinnabun. SMTP delivery with Handlebars templates.
Installation
bun add @cinnabun/mailQuick Start
import { CinnabunApp, CinnabunFactory } from "@cinnabun/core";
import { MailModule, MailPlugin, SmtpAdapter } from "@cinnabun/mail";
@CinnabunApp({
port: 3000,
scanPaths: [],
imports: [
MailModule.forRoot({
adapter: SmtpAdapter,
smtp: {
host: process.env.SMTP_HOST ?? "localhost",
port: 587,
secure: false,
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS,
},
},
}),
],
plugins: [new MailPlugin()],
})
class App {}
CinnabunFactory.run(App);Sending email
import { MailService } from "@cinnabun/mail";
@Service()
class NotificationService {
constructor(private mail: MailService) {}
async sendWelcome(to: string, name: string) {
await this.mail.send({
to,
subject: "Welcome",
html: await this.mail.render("welcome", { name }),
});
}
}Adapters
- SmtpAdapter — SMTP delivery
- ConsoleAdapter — Logs to console (development)
License
MIT
