evsmtp

package
v0.0.0-...-b8b9e6a Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: MIT Imports: 25 Imported by: 2

Documentation

Overview

Package evsmtp is a generated GoMock package.

Index

Constants

View Source
const (
	ErrPrefix        = "evsmtp: "
	ErrConnectionMsg = ErrPrefix + "connection was not created"
	DefaultEmail     = "user@example.org"
	DefaultSMTPPort  = 25
	DefaultHelloName = "localhost"
)

Configuration constants

View Source
const (
	RandomRCPTStage = CloseStage + 1
	ConnectionStage = RandomRCPTStage + 1
)

Constants of stages

View Source
const (
	// DefaultTimeoutConnection is timeout for connection
	DefaultTimeoutConnection = 5 * time.Second
	// DefaultTimeoutResponse is timeout for communication with smtp server
	DefaultTimeoutResponse = 5 * time.Second
)
View Source
const TCPConnection = "tcp"

TCPConnection is tcp name

Variables

View Source
var (
	// ErrConnection is error of connection
	ErrConnection = NewError(ConnectionStage, errors.New(ErrConnectionMsg))
	// DefaultFromEmail is address, used as default From email
	DefaultFromEmail = evmail.FromString(DefaultEmail)
)

Functions

func DefaultRandomCacheKeyGetter

func DefaultRandomCacheKeyGetter(email evmail.Address) interface{}

DefaultRandomCacheKeyGetter generates of cache key for RandomRCPT

func DirectDial

func DirectDial(ctx context.Context, addr, proxyURL string) (smtpclient.SMTPClient, error)

DirectDial generates smtpclient.SMTPClient (smtp.Client)

func ExtID

func ExtID() int8

ExtID returns register extent id, used for msgpack.RegisterExt

func H12IODial

func H12IODial(ctx context.Context, addr, proxyURL string) (smtpclient.SMTPClient, error)

H12IODial generates smtpclient.SMTPClient (smtp.Client) with proxy in socks.Dial

func SetExtID

func SetExtID(rExt int8)

SetExtID sets register extent id, used for msgpack.RegisterExt

Types

type ARandomRCPT

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

ARandomRCPT is abstract realization of RandomRCPT

func (*ARandomRCPT) Call

func (a *ARandomRCPT) Call(sm SendMail, email evmail.Address) []error

Call is calling of RandomRCPTFunc

type ASMTPError

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

ASMTPError isa abstract struct for Checker errors

func (*ASMTPError) DecodeMsgpack

func (a *ASMTPError) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack implements decoder for msgpack

func (*ASMTPError) EncodeMsgpack

func (a *ASMTPError) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack implements encoder for msgpack

func (*ASMTPError) Error

func (a *ASMTPError) Error() string

func (*ASMTPError) Stage

func (a *ASMTPError) Stage() SendMailStage

Stage returns stage of error

func (*ASMTPError) Unwrap

func (a *ASMTPError) Unwrap() error

type AliasError

type AliasError error

AliasError is alias to fix msgpack

func ErrorsToEVSMTPErrors

func ErrorsToEVSMTPErrors(errs []error) (Errs []AliasError)

ErrorsToEVSMTPErrors converts []error to []AliasError It is used like fix of msgpack problems https://github.com/vmihailenco/msgpack/issues/294

type Checker

type Checker interface {
	Validate(mxs MXs, input Input) []error
}

Checker is SMTP validation

func NewChecker

func NewChecker(dto CheckerDTO) Checker

NewChecker instantiates Checker

func NewCheckerCacheRandomRCPT

func NewCheckerCacheRandomRCPT(checker CheckerWithRandomRCPT, cache evcache.Interface, getKey RandomCacheKeyGetter) Checker

NewCheckerCacheRandomRCPT creates Checker with caching of RandomRCPT calling

type CheckerDTO

type CheckerDTO struct {
	SendMailFactory SendMailDialerFactory
	RandomEmail     RandomEmail
	Options         Options
}

CheckerDTO is DTO for NewChecker

type CheckerWithRandomRCPT

type CheckerWithRandomRCPT interface {
	Checker
	RandomRCPT
}

CheckerWithRandomRCPT is used for caching of RandomRCPT

type DefaultError

type DefaultError struct {
	ASMTPError
}

DefaultError is default error

type DialFunc

type DialFunc func(ctx context.Context, addr, proxyURL string) (smtpclient.SMTPClient, error)

DialFunc is function type to create smtpclient.SMTPClient

type Error

type Error interface {
	error
	Stage() SendMailStage
	Unwrap() error
}

Error is interface of Checker errors

func NewError

func NewError(stage SendMailStage, err error) Error

NewError is constructor for DefaultError

type FuncLookupMX

type FuncLookupMX func(domain string) (MXs, error)

FuncLookupMX returns MXs

type Input

type Input interface {
	Email() evmail.Address
	Options
}

Input describes data for Checker

func NewInput

func NewInput(email evmail.Address, opts Options) Input

NewInput instantiates Input

type MXs

type MXs = []*net.MX

MXs is short alias for []*net.MX

func LookupMX

func LookupMX(domain string) (MXs, error)

LookupMX is default realization for looking net.MX

type MockChecker

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

MockChecker is a mock of Checker interface

func NewMockChecker

func NewMockChecker(ctrl *gomock.Controller) *MockChecker

NewMockChecker creates a new mock instance

func (*MockChecker) EXPECT

func (m *MockChecker) EXPECT() *MockCheckerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockChecker) Validate

func (m *MockChecker) Validate(mxs MXs, input Input) []error

Validate mocks base method

type MockCheckerMockRecorder

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

MockCheckerMockRecorder is the mock recorder for MockChecker

func (*MockCheckerMockRecorder) Validate

func (mr *MockCheckerMockRecorder) Validate(mxs, input interface{}) *gomock.Call

Validate indicates an expected call of Validate

type MockCheckerWithRandomRCPT

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

MockCheckerWithRandomRCPT is a mock of CheckerWithRandomRCPT interface

func NewMockCheckerWithRandomRCPT

func NewMockCheckerWithRandomRCPT(ctrl *gomock.Controller) *MockCheckerWithRandomRCPT

NewMockCheckerWithRandomRCPT creates a new mock instance

func (*MockCheckerWithRandomRCPT) Call

func (m *MockCheckerWithRandomRCPT) Call(sm SendMail, email evmail.Address) []error

Call mocks base method

func (*MockCheckerWithRandomRCPT) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockCheckerWithRandomRCPT) Validate

func (m *MockCheckerWithRandomRCPT) Validate(mxs MXs, input Input) []error

Validate mocks base method

type MockCheckerWithRandomRCPTMockRecorder

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

MockCheckerWithRandomRCPTMockRecorder is the mock recorder for MockCheckerWithRandomRCPT

func (*MockCheckerWithRandomRCPTMockRecorder) Call

func (mr *MockCheckerWithRandomRCPTMockRecorder) Call(sm, email interface{}) *gomock.Call

Call indicates an expected call of Call

func (*MockCheckerWithRandomRCPTMockRecorder) Validate

func (mr *MockCheckerWithRandomRCPTMockRecorder) Validate(mxs, input interface{}) *gomock.Call

Validate indicates an expected call of Validate

type MockRandomRCPT

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

MockRandomRCPT is a mock of RandomRCPT interface

func NewMockRandomRCPT

func NewMockRandomRCPT(ctrl *gomock.Controller) *MockRandomRCPT

NewMockRandomRCPT creates a new mock instance

func (*MockRandomRCPT) Call

func (m *MockRandomRCPT) Call(sm SendMail, email evmail.Address) []error

Call mocks base method

func (*MockRandomRCPT) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

type MockRandomRCPTMockRecorder

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

MockRandomRCPTMockRecorder is the mock recorder for MockRandomRCPT

func (*MockRandomRCPTMockRecorder) Call

func (mr *MockRandomRCPTMockRecorder) Call(sm, email interface{}) *gomock.Call

Call indicates an expected call of Call

type Options

type Options interface {
	EmailFrom() evmail.Address
	HelloName() string
	Proxy() string
	TimeoutConnection() time.Duration
	TimeoutResponse() time.Duration
	Port() int
}

Options describes smtp options

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns options with default values

func EmptyOptions

func EmptyOptions() Options

EmptyOptions returns empty options to avoid rewriting of default values

func NewOptions

func NewOptions(dto OptionsDTO) Options

NewOptions instantiates Options

type OptionsDTO

type OptionsDTO struct {
	EmailFrom   evmail.Address
	HelloName   string
	Proxy       string
	TimeoutCon  time.Duration
	TimeoutResp time.Duration
	Port        int
}

OptionsDTO is dto for NewOptions

type RandomCacheKeyGetter

type RandomCacheKeyGetter func(email evmail.Address) interface{}

RandomCacheKeyGetter is type of function to get cache key

type RandomEmail

type RandomEmail func(domain string) (evmail.Address, error)

RandomEmail is function type to generate random email for checking of Catching All emails by RCPTs

type RandomRCPT

type RandomRCPT interface {
	Call(sm SendMail, email evmail.Address) []error
	// contains filtered or unexported methods
}

RandomRCPT Need to realize of is-a relation (inheritance)

type RandomRCPTFunc

type RandomRCPTFunc func(sm SendMail, email evmail.Address) (errs []error)

RandomRCPTFunc is function for checking of Catching All

type SafeSendMailStage

type SafeSendMailStage struct {
	SendMailStage
	// contains filtered or unexported fields
}

SafeSendMailStage is thread safe SendMailStage

func (*SafeSendMailStage) Get

Get returns stage

func (*SafeSendMailStage) Set

func (s *SafeSendMailStage) Set(val SendMailStage)

Set sets stage

type SendMail

type SendMail interface {
	Client() smtpclient.SMTPClient
	Hello(helloName string) error
	Auth(a smtp.Auth) error
	Mail(from string) error
	RCPTs(addrs []string) map[string]error
	Data() (io.WriteCloser, error)
	Write(w io.WriteCloser, msg []byte) error
	Quit() error
	Close() error
}

SendMail is interface of custom realization as smtp.SendMail

func NewSendMail

func NewSendMail(client smtpclient.SMTPClient, tlsConfig *tls.Config) SendMail

NewSendMail instantiates SendMail

type SendMailDialerFactory

type SendMailDialerFactory func(ctx context.Context, host string, opts Options) (SendMail, error)

SendMailDialerFactory is factory for SendMail with dialing

func NewSendMailCustom

func NewSendMailCustom(dialFunc DialFunc, tlsConfig *tls.Config, factory SendMailFactory) SendMailDialerFactory

NewSendMailCustom creates SendMailFactory with dialing and customization calling of SendMailFactory

func NewSendMailFactory

func NewSendMailFactory(dialFunc DialFunc, tlsConfig *tls.Config) SendMailDialerFactory

NewSendMailFactory creates SendMailDialerFactory

type SendMailFactory

type SendMailFactory func(client smtpclient.SMTPClient, tlsConfig *tls.Config) SendMail

SendMailFactory is factory for SendMail

type SendMailStage

type SendMailStage uint8

SendMailStage is stage type of SendMail

const (
	ClientStage SendMailStage = iota + 1
	HelloStage
	AuthStage
	MailStage
	RCPTsStage
	QuitStage
	CloseStage
)

Constants of stages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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