server

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ReadTimeout default 2 secs
	ReadTimeout = _timeout * time.Second
	// WriteTimeout default 2 secs
	WriteTimeout = _timeout * time.Second

	// MaxMessageBytes default 10 Mb
	MaxMessageBytes = 10 * _mb
	// MaxRecipients default 50
	MaxRecipients = 50
	// AllowInsecureAuth default true
	AllowInsecureAuth = true
	// EnableSMTPUTF8 default true
	EnableSMTPUTF8 = true
)
View Source
var ErrorAuthAnonCredentials = errors.New("user has not authenticated. anonymous access is not allowed")

ErrorAuthAnonCredentials error for unauthorized access

View Source
var ErrorAuthCredentials = errors.New("invalid username or password")

ErrorAuthCredentials error for invalid authentication

Functions

This section is empty.

Types

type AuthFunc

type AuthFunc interface {
	Authenticate(username, password string) error
}

AuthFunc authentitate function type

func NewHardcodedAuthFunc

func NewHardcodedAuthFunc(username, password string) AuthFunc

NewHardcodedAuthFunc hardcoded credentials auth function

func NoOpAuthFunc

func NoOpAuthFunc() AuthFunc

NoOpAuthFunc default auth forbidden auth function

type Option

type Option interface {
	// contains filtered or unexported methods
}

An Option configures a server.

func WithAnnonAuthAllowed

func WithAnnonAuthAllowed(isAnonAllowed bool) Option

WithAnnonAuthAllowed whether to allow anon login or not, added for perf tests

func WithAuth

func WithAuth(auth AuthFunc) Option

WithAuth sets auth

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) Option

WithTLSConfig sets tls

func WithUpstreamServers

func WithUpstreamServers(reg upstream.Registry) Option

WithUpstreamServers sets the upstream server handler

type SMTPServer

type SMTPServer interface {
	Shutdown() error
	ListenAndServe() error
}

SMTPServer abstration

type SrvBackend

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

func NewServer

func NewServer(ctx context.Context, logger *slog.Logger, addr, domain string) *SrvBackend

NewServer prepares SMTP server

func (*SrvBackend) ListenAndServe

func (srv *SrvBackend) ListenAndServe() error

func (*SrvBackend) Shutdown

func (srv *SrvBackend) Shutdown() error

func (*SrvBackend) WithOptions

func (srv *SrvBackend) WithOptions(opts ...Option) *SrvBackend

Jump to

Keyboard shortcuts

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