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

mailtest

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package mailtest provides a mail.Sender for tests: it records the messages it is given instead of delivering them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sender

type Sender struct {
	// Err, when set, is returned by every Send.
	Err error
	// contains filtered or unexported fields
}

Sender records every message it sends. It rejects an invalid message with mail.ErrInvalidMessage, exactly as a real sender would. When Err is set, Send returns it and records nothing. A Sender is safe for concurrent use; its zero value is ready to use.

func (*Sender) Messages

func (s *Sender) Messages() []mail.Message

Messages returns the messages sent so far, oldest first.

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, message mail.Message) error

Send validates message, then records it, or returns Err.

Jump to

Keyboard shortcuts

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