smtpserver

package
v0.2.0-dev Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSMTPSService

func NewSMTPSService(conf Config, tlsOpts TLSOptions) service.Service

func NewSMTPService

func NewSMTPService(conf Config) service.Service

func NewServer

func NewServer(conf Config, tlsOpts *TLSOptions, logger *slog.Logger) (*smtp.Server, error)

Types

type Backend

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

Backend implements SMTP server methods.

func (*Backend) NewSession

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

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

type Config

type Config struct {
	Addr              string // "localhost:1025"
	Domain            string // "localhost"
	WriteTimeout      int    // 10 seconds
	ReadTimeout       int    // 10 seconds
	MaxMessageBytes   int    // 1024 * 1024
	MaxRecipients     int    // 50
	AllowInsecureAuth bool   // true
}

type Server

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

func (*Server) Name

func (s *Server) Name() string

func (*Server) SetLogger

func (s *Server) SetLogger(logger *slog.Logger)

func (*Server) Start

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

func (*Server) Stop

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

type Session

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

Session represents an SMTP session.

func (*Session) Auth

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

Auth handles authentication.

func (*Session) AuthMechanisms

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

AuthMechanisms returns available authentication mechanisms.

func (*Session) Data

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

Data handles the message data.

func (*Session) Logout

func (s *Session) Logout() error

Logout closes the session.

func (*Session) Mail

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

Mail handles MAIL FROM command.

func (*Session) Rcpt

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

Rcpt handles RCPT TO command.

func (*Session) Reset

func (s *Session) Reset()

Reset clears the session state.

type TLSOptions

type TLSOptions struct {
	CertFile string
	KeyFile  string
}

Jump to

Keyboard shortcuts

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