ss-keel-mail
ss-keel-mail provides a Mailer implementation with support for multiple transports: SMTP, Resend, and SendGrid.
Implements: Mailer
Planned Installation
Section titled “Planned Installation”go get github.com/slice-soft/ss-keel-mailPlanned Usage
Section titled “Planned Usage”import "github.com/slice-soft/ss-keel-mail"
mailer := ssmail.NewSMTP(ssmail.SMTPConfig{ Host: os.Getenv("SMTP_HOST"), Port: 587, Username: os.Getenv("SMTP_USER"), Password: os.Getenv("SMTP_PASS"), From: "noreply@example.com",})Resend
Section titled “Resend”mailer := ssmail.NewResend(ssmail.ResendConfig{ APIKey: os.Getenv("RESEND_API_KEY"), From: "noreply@example.com",})SendGrid
Section titled “SendGrid”mailer := ssmail.NewSendGrid(ssmail.SendGridConfig{ APIKey: os.Getenv("SENDGRID_API_KEY"), From: "noreply@example.com",})Sending Email
Section titled “Sending Email”All transports implement the same Mailer interface:
err := mailer.Send(ctx, core.Mail{ To: []string{"user@example.com"}, Subject: "Welcome to My App", HTMLBody: "<h1>Welcome!</h1><p>Thanks for signing up.</p>", TextBody: "Welcome! Thanks for signing up.",})With Attachments
Section titled “With Attachments”pdfData, _ := os.ReadFile("invoice.pdf")
mailer.Send(ctx, core.Mail{ To: []string{"user@example.com"}, Subject: "Your Invoice", HTMLBody: "<p>Please find your invoice attached.</p>", Attachments: []core.MailAttachment{ { Filename: "invoice.pdf", ContentType: "application/pdf", Data: pdfData, }, },})Inject into Module
Section titled “Inject into Module”func (m *AuthModule) Register(app *core.App) { mailer := ssmail.NewResend(ssmail.ResendConfig{ APIKey: os.Getenv("RESEND_API_KEY"), From: "noreply@example.com", }) app.RegisterController(NewAuthController(mailer))}