mailsender

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package mailsender sends transactional email via SMTP or the Resend HTTP API.

Index

Constants

This section is empty.

Variables

View Source
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

type ResendEmailSender struct {
	APIKey      string
	FromAddress string
	HTTPClient  *http.Client
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL