mail

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

README

User email (password reset / verification)

Cross-repo behaviour and ops: docs/github/transactional-email.md (sibling docs repo).

This module owns:

  • email_verified on users
  • user_email_tokens (hashed one-time tokens)
  • SES SMTP mailer under modules/user/mail/
  • HTTP: /password-reset/*, /email-verification/*

Templates live in modules/user/mail/templates/. Iterate locally with Mailpit; do not treat SES console templates as source of truth.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRateLimited = errors.New("email rate limited")
	ErrDisabled    = errors.New("smtp disabled")
)

Functions

This section is empty.

Types

type Mailer

type Mailer interface {
	Send(ctx context.Context, msg Message) error
}

Mailer sends transactional email.

func NewNoopMailer

func NewNoopMailer() Mailer

func NewSMTPMailer

func NewSMTPMailer(cfg SMTPConfig) Mailer

type Message

type Message struct {
	To       string
	Subject  string
	TextBody string
	HTMLBody string
}

Message is a transactional email payload.

type RateLimitedMailer

type RateLimitedMailer struct {
	// contains filtered or unexported fields
}

RateLimitedMailer wraps a Mailer with a process-local rolling hourly send cap. Assumes a single backend instance.

func NewRateLimitedMailer

func NewRateLimitedMailer(inner Mailer, hourlyLimit int) *RateLimitedMailer

func (*RateLimitedMailer) Send

func (m *RateLimitedMailer) Send(ctx context.Context, msg Message) error

type RenderedEmail

type RenderedEmail struct {
	Subject  string
	TextBody string
	HTMLBody string
}

func RenderEmailVerify

func RenderEmailVerify(data TemplateData) (RenderedEmail, error)

func RenderPasswordReset

func RenderPasswordReset(data TemplateData) (RenderedEmail, error)

type SMTPConfig

type SMTPConfig struct {
	Host     string
	Port     int
	Username string
	Password string
	From     string
	FromName string
}

SMTPConfig holds SES SMTP (or compatible) connection settings.

type TemplateData

type TemplateData struct {
	Username   string
	ActionURL  string
	ExpiryNote string
}

Jump to

Keyboard shortcuts

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