smtp

package
v0.9.17 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NoUserCode SMTP code
	NoUserCode = 550
	// BannedCode SMTP code
	BannedCode = 554
)
View Source
const GraylistCode = 451

GraylistCode SMTP code

Variables

View Source
var (
	// NoUserEnhancedCode enhanced SMTP code
	NoUserEnhancedCode = smtp.EnhancedCode{5, 5, 0}
	// BannedEnhancedCode enhanced SMTP code
	BannedEnhancedCode = smtp.EnhancedCode{5, 5, 4}
	// ErrBanned returned to banned hosts
	ErrBanned = &smtp.SMTPError{
		Code:         BannedCode,
		EnhancedCode: BannedEnhancedCode,
		Message:      "please, don't bother me anymore, kupo.",
	}
	// ErrNoUser returned when no such mailbox found
	ErrNoUser = &smtp.SMTPError{
		Code:         NoUserCode,
		EnhancedCode: NoUserEnhancedCode,
		Message:      "no such user here, kupo.",
	}
)
View Source
var (
	// ErrInvalidEmail for invalid emails :)
	ErrInvalidEmail = errors.New("please, provide valid email address")
	// GraylistEnhancedCode is GraylistCode in enhanced code notation
	GraylistEnhancedCode = smtp.EnhancedCode{4, 5, 1}
)

Functions

This section is empty.

Types

type Caller added in v0.9.10

type Caller interface {
	SetSendmail(func(string, string, string) error)
}

Caller is Sendmail caller

type Client

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

SMTP client

func (Client) Send

func (c Client) Send(from, to, data string) error

Send email

type Config added in v0.9.1

type Config struct {
	Domains []string
	Port    string

	TLSCerts    []string
	TLSKeys     []string
	TLSPort     string
	TLSRequired bool

	Logger  *zerolog.Logger
	MaxSize int
	Bot     matrixbot
	Callers []Caller
	Relay   *RelayConfig
}

type Listener added in v0.9.9

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

Listener that rejects connections from banned hosts

func NewListener added in v0.9.9

func NewListener(port string, tlsConfig *tls.Config, isBanned func(net.Addr) bool, log *zerolog.Logger) (*Listener, error)

func (*Listener) Accept added in v0.9.9

func (l *Listener) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener.

func (*Listener) Addr added in v0.9.9

func (l *Listener) Addr() net.Addr

Addr returns the listener's network address.

func (*Listener) Close added in v0.9.9

func (l *Listener) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

func (*Listener) SetTLSConfig added in v0.9.13

func (l *Listener) SetTLSConfig(cfg *tls.Config)

type MailSender added in v0.9.15

type MailSender interface {
	Send(from, to, data string) error
}

type Manager added in v0.9.9

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

func NewManager added in v0.9.9

func NewManager(cfg *Config) *Manager

NewManager creates new SMTP server manager

func (*Manager) Start added in v0.9.9

func (m *Manager) Start() error

Start SMTP server

func (*Manager) Stop added in v0.9.9

func (m *Manager) Stop()

Stop SMTP server

type RelayConfig added in v0.9.15

type RelayConfig struct {
	Host     string
	Port     string
	Usename  string
	Password string
}

type TLSConfig added in v0.9.13

type TLSConfig struct {
	Listener *Listener
	Config   *tls.Config
	Certs    []string
	Keys     []string
	Port     string
	Mu       sync.Mutex
}

Jump to

Keyboard shortcuts

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