smtptest

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package smtptest provides a minimal in-process SMTP server for tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TLSConfigs

func TLSConfigs(t *testing.T) (*tls.Config, *tls.Config)

TLSConfigs returns a server config with a fresh self-signed 127.0.0.1 cert and a client config trusting it.

Types

type Options

type Options struct {
	// TLSConfig, when set, advertises STARTTLS.
	TLSConfig *tls.Config
	// AdvertiseAuth advertises AUTH PLAIN.
	AdvertiseAuth bool
	// RejectRcpt makes every RCPT TO fail with 550.
	RejectRcpt bool
}

Options controls server behaviour.

type Server

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

Server is a running fake SMTP server.

func Start

func Start(t *testing.T, opts Options) *Server

Start listens on 127.0.0.1 and serves until the test ends.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns host:port.

func (*Server) Sessions

func (s *Server) Sessions() <-chan Session

Sessions yields each completed (or attempted) transaction.

type Session

type Session struct {
	From      string
	Data      string
	Rcpts     []string
	AuthLines []string
	TLS       bool
}

Session is one captured SMTP transaction.

Jump to

Keyboard shortcuts

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