Help us shape the future of Go! Take the 2026 Go Developer Survey

mailer

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Overview

Package mailer renders templates and sends transactional email over SMTP.

Index

Constants

View Source
const DefaultSendTimeout = 15 * time.Second

DefaultSendTimeout bounds one SMTP transaction.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mailer

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

Mailer renders and delivers transactional email.

func New

func New(cfg config.MailerConfig, opts Options) Mailer

New builds a mailer from SMTP settings. Every compiled template is parsed eagerly so a broken template fails the boot, not the first send.

type Message

type Message struct {
	// To is the recipient address.
	To string

	// Subject is the message subject.
	Subject string

	// Template names resolve to matching HTML and text templates.
	Template string

	// Data feeds the template's .Data tree.
	Data map[string]any
}

Message is a message to render and send.

type Options

type Options struct {
	// Templates is the source of template files.
	Templates fs.FS

	// LogoURL is available to templates.
	LogoURL string

	// Logger receives send attempts and failures. Nil disables logging.
	Logger logger.Logger

	// SendTimeout bounds one SMTP transaction when ctx has no
	// deadline. Zero uses DefaultSendTimeout.
	SendTimeout time.Duration
}

Options configures New.

Jump to

Keyboard shortcuts

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