mailtest

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mailtest tests the mail an app sends: a quiet log-driver Mailer to provide, and helpers reading what it kept.

m := mailtest.New()
app := web.New(web.Provide(m))
… sign up …
msg := mailtest.Last(t, m)
if msg.Recipients[0] != "ada@example.com" || !strings.Contains(msg.Text, "Welcome") { … }

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Last

func Last(t testing.TB, m *mail.Mailer) mail.Sent

Last is the last message m kept; the test fails when there is none.

func New

func New(cfg ...mail.Config) *mail.Mailer

New is a log-driver Mailer that logs nothing, its sender test@example.com unless cfg says otherwise.

func Sent

func Sent(t testing.TB, m *mail.Mailer) []mail.Sent

Sent waits for the messages SendLater queued, then returns every message m kept.

func To

func To(t testing.TB, m *mail.Mailer, addr string) []mail.Sent

To is the messages m kept that went to addr (To, Cc or Bcc).

Types

This section is empty.

Jump to

Keyboard shortcuts

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