smtpsrv

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Domain         string
	AllowedDomains []string
	TLSConfig      *tls.Config
	MaxRecipients  int

	BackgroundContext func() context.Context
	Logger            *log.Logger

	AuthorizeFunc   func(ctx context.Context, id string) (context.Context, error)
	CreateAlertFunc func(ctx context.Context, a *alert.Alert) error
}

Config is used to configure the SMTP server.

type SMTPLogger added in v0.32.0

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

SMTPLogger implements the smtp.Logger interface using the main app Logger.

func (*SMTPLogger) Printf added in v0.32.0

func (l *SMTPLogger) Printf(format string, v ...interface{})

Printf adheres to smtp.Server's Logger interface.

func (*SMTPLogger) Println added in v0.32.0

func (l *SMTPLogger) Println(v ...interface{})

Print adheres to smtp.Server's Logger interface.

type Server

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

Server implements an SMTP server that creates alerts.

func NewServer

func NewServer(cfg Config) *Server

NewServer creates a new Server.

func (*Server) NewSession

func (s *Server) NewSession(_ *smtp.Conn) (smtp.Session, error)

NewSession implements the smtp.Backend interface.

func (*Server) ServeSMTP

func (s *Server) ServeSMTP(l net.Listener) error

ServeSMTP starts the SMTP server on the given listener.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the SMTP server.

type Session

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

Session implements an SMTP session that creates alerts.

func (*Session) AuthPlain

func (s *Session) AuthPlain(username, password string) error

AuthPlain is called when a client attempts to authenticate using the PLAIN auth mechanism. It always returns an error, indicating that PLAIN auth is not supported.

func (*Session) Data

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

Data is called when a new SMTP message is received.

func (*Session) Logout

func (s *Session) Logout() error

Logout is called when the client requests to log out.

func (*Session) Mail

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

Mail is called when a new SMTP message is received (MAIL FROM). It checks that the sender is valid and stores it in the session.

func (*Session) Rcpt

func (s *Session) Rcpt(recipient string, opts *smtp.RcptOptions) error

Rcpt is called when a new SMTP message is received (RCPT TO). It checks that the recipient is valid and stores it in the session.

It also checks that the recipient is authorized to create alerts.

func (*Session) Reset

func (s *Session) Reset()

Reset resets the session state.

Jump to

Keyboard shortcuts

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