smtpserver

package
v0.4.0-dev Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

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

func NewService

func NewService(conf Config, logger *slog.Logger) service.Service

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
	RequireAuth       bool   // false
	AllowInsecureAuth bool   // true

	// TLS enables SMTPS mode when non-nil.
	TLS *tlsprovider.Config
}

func (Config) Validate

func (c Config) Validate() error

type Server

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

func (*Server) Name

func (s *Server) Name() string

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

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.

Jump to

Keyboard shortcuts

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