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

mail

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package mail defines how the auth module sends email.

A project passes a Mailer in auth.Config: usually the Resend adapter in mail/resend, a Writer during local development, or mailtest.Recorder in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mailer

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

Mailer sends one email. The auth module calls Send from a background goroutine and retries on error, so an implementation should return an error for any failure worth retrying.

type Message

type Message struct {
	To      string
	Subject string
	// Text is the plain-text body. It's always set.
	Text string
	// HTML is an optional HTML body.
	HTML string
	// IdempotencyKey is the same on every retry of one message, so a
	// provider that supports it can drop duplicates.
	IdempotencyKey string
}

Message is one email.

type Writer

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

Writer is a Mailer for local development that prints each email to an io.Writer instead of sending it.

Emails contain working links with live tokens, so a Writer must never be used in production: anyone who can read its output can take over accounts. auth.New logs a warning when it's given one.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a Writer that prints to w. For local development only.

func (*Writer) Send

func (w *Writer) Send(_ context.Context, m Message) error

Send prints m.

Directories

Path Synopsis
Package mailtest provides a fake Mailer for tests.
Package mailtest provides a fake Mailer for tests.
Package resend sends the auth module's email through Resend (https://resend.com), the standard transactional email provider.
Package resend sends the auth module's email through Resend (https://resend.com), the standard transactional email provider.

Jump to

Keyboard shortcuts

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