smtptest

package
v2.34.16 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMockSMTPServer

func CreateMockSMTPServer(be *Backend, useTLS bool) (*smtp.Server, net.Listener, error)

nolint:revive // Yes, useTLS is a control flag.

func PingClient

func PingClient(listen net.Listener, useTLS bool, startTLS bool) (*smtp.Client, error)

Types

type Backend

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

func NewBackend

func NewBackend(cfg Config) *Backend

func (*Backend) LastMessage

func (b *Backend) LastMessage() *Message

LastMessage returns a copy of the last message received by the backend.

func (*Backend) NewSession

func (b *Backend) NewSession(c *smtp.Conn) (smtp.Session, error)

NewSession is called after client greeting (EHLO, HELO).

func (*Backend) Reset

func (b *Backend) Reset()

type Config

type Config struct {
	AuthMechanisms                                       []string
	AcceptedIdentity, AcceptedUsername, AcceptedPassword string
	FailOnDataFn                                         func() error
}

type Message

type Message struct {
	AuthMech                     string
	Identity, Username, Password string // Auth
	From                         string
	To                           []string // Address
	Subject, Contents            string   // Content
}

type Session

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

func (*Session) Auth

func (s *Session) Auth(mech string) (sasl.Server, error)

Auth is the handler for supported authenticators.

func (*Session) AuthMechanisms

func (s *Session) AuthMechanisms() []string

AuthMechanisms returns a slice of available auth mechanisms; only PLAIN is supported in this example.

func (*Session) Data

func (s *Session) Data(r io.Reader) error

func (*Session) Logout

func (*Session) Logout() error

func (*Session) Mail

func (s *Session) Mail(from string, _ *smtp.MailOptions) error

func (*Session) Rcpt

func (s *Session) Rcpt(to string, _ *smtp.RcptOptions) error

func (*Session) Reset

func (*Session) Reset()

Jump to

Keyboard shortcuts

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