Documentation
¶
Overview ¶
Package mailsender sends transactional email via SMTP or the Resend HTTP API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadAddress = errors.New("not an e-mail address")
ErrBadAddress - the recipient isn't one e-mail address.
Functions ¶
This section is empty.
Types ¶
type EmailConfig ¶
type EmailConfig struct {
SMTPHost string
SMTPPort int
SMTPUser string
SMTPPassword string
FromAddress string
// Timeout bounds the whole SMTP session (0 - defaultSMTPTimeout).
Timeout time.Duration
}
EmailConfig holds SMTP configuration (can be populated from config package)
type EmailSender ¶
type EmailSender interface {
// SendPlain sends a transactional email with explicit subject and body (UTF-8 plain text).
SendPlain(to, subject, body string) error
}
EmailSender sends emails (password reset, notifications, etc.)
type NoopEmailSender ¶
type NoopEmailSender struct{}
NoopEmailSender is a no-op implementation for when email is not configured
func (NoopEmailSender) SendPlain ¶
func (NoopEmailSender) SendPlain(to, subject, body string) error
SendPlain does nothing
type ResendEmailSender ¶
ResendEmailSender sends mail via Resend HTTP API (https://resend.com/docs/api-reference/emails/send-email).
func NewResendEmailSender ¶
func NewResendEmailSender(apiKey, fromAddress string, timeout time.Duration) *ResendEmailSender
NewResendEmailSender creates a sender. apiKey is the Resend API key; fromAddress must be an allowed sender in Resend; timeout bounds a request to Resend.
func (*ResendEmailSender) SendPlain ¶
func (s *ResendEmailSender) SendPlain(to, subject, body string) error
SendPlain sends UTF-8 plain text email.
type SMTPEmailSender ¶
type SMTPEmailSender struct {
// contains filtered or unexported fields
}
SMTPEmailSender sends emails via SMTP
func NewSMTPEmailSender ¶
func NewSMTPEmailSender(cfg EmailConfig) *SMTPEmailSender
NewSMTPEmailSender creates a new SMTP email sender
func (*SMTPEmailSender) SendPlain ¶
func (s *SMTPEmailSender) SendPlain(to, subject, body string) error
SendPlain sends UTF-8 plain text email.