Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultRandomCacheKeyGetter(email evmail.Address) interface{}
- func DirectDial(ctx context.Context, addr, proxyURL string) (smtpclient.SMTPClient, error)
- func ExtID() int8
- func H12IODial(ctx context.Context, addr, proxyURL string) (smtpclient.SMTPClient, error)
- func SetExtID(rExt int8)
- type ARandomRCPT
- type ASMTPError
- type AliasError
- type Checker
- type CheckerCacheRandomRCPTStruct
- type CheckerDTO
- type CheckerStruct
- type CheckerWithRandomRCPT
- type DefaultError
- type DialFunc
- type Error
- type FuncLookupMX
- type Input
- type InputStruct
- type MXs
- type Options
- type OptionsDTO
- type OptionsStruct
- type RandomCacheKeyGetter
- type RandomEmail
- type RandomRCPT
- type RandomRCPTFunc
- type SafeSendMailStage
- type SendMail
- type SendMailDialerFactory
- type SendMailFactory
- type SendMailStage
- type SendMailStruct
- func (s *SendMailStruct) Auth(a smtp.Auth) error
- func (s *SendMailStruct) Client() smtpclient.SMTPClient
- func (s *SendMailStruct) Close() error
- func (s *SendMailStruct) Data() (io.WriteCloser, error)
- func (s *SendMailStruct) Hello(helloName string) error
- func (s *SendMailStruct) Mail(from string) error
- func (s *SendMailStruct) Quit() error
- func (s *SendMailStruct) RCPTs(addrs []string) map[string]error
- func (s *SendMailStruct) Write(w io.WriteCloser, msg []byte) error
Constants ¶
const ( ErrPrefix = "evsmtp: " ErrConnectionMsg = ErrPrefix + "connection was not created" DefaultEmail = "user@example.org" DefaultSMTPPort = 25 DefaultHelloName = "localhost" )
Configuration constants
const ( RandomRCPTStage = CloseStage + 1 ConnectionStage = RandomRCPTStage + 1 )
Constants of stages
const ( // DefaultTimeoutConnection is timeout for connection DefaultTimeoutConnection = 5 * time.Second // DefaultTimeoutResponse is timeout for communication with smtp server DefaultTimeoutResponse = 5 * time.Second )
const TCPConnection = "tcp"
TCPConnection is tcp name
Variables ¶
var ( // ErrConnection is error of connection ErrConnection = NewError(ConnectionStage, errors.New(ErrConnectionMsg)) // DefaultFromEmail is address, used as default From email DefaultFromEmail = evmail.FromString(DefaultEmail) )
var DirectDialVar = DirectDial
var H12ioDialVar = socks.Dial
var SmtpNewClientVar = smtp.NewClient
Functions ¶
func DefaultRandomCacheKeyGetter ¶
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 H12IODial ¶
func H12IODial(ctx context.Context, addr, proxyURL string) (smtpclient.SMTPClient, error)
H12IODial generates smtpclient.SMTPClient (smtp.Client) with proxy in socks.Dial
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
func (*ARandomRCPT) Get ¶
func (a *ARandomRCPT) Get() RandomRCPTFunc
func (*ARandomRCPT) Set ¶
func (a *ARandomRCPT) Set(fn 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) 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 ¶
Checker is SMTP validation
func NewCheckerCacheRandomRCPT ¶
func NewCheckerCacheRandomRCPT(checker CheckerWithRandomRCPT, cache evcache.Interface, getKey RandomCacheKeyGetter) Checker
NewCheckerCacheRandomRCPT creates Checker with caching of RandomRCPT calling
type CheckerCacheRandomRCPTStruct ¶
type CheckerCacheRandomRCPTStruct struct { CheckerWithRandomRCPT RandomRCPTOpt RandomRCPT Cache evcache.Interface GetKey RandomCacheKeyGetter }
func (CheckerCacheRandomRCPTStruct) RandomRCPT ¶
func (c CheckerCacheRandomRCPTStruct) RandomRCPT(sm SendMail, email evmail.Address) (errs []error)
type CheckerDTO ¶
type CheckerDTO struct { SendMailFactory SendMailDialerFactory RandomEmail RandomEmail Options Options }
CheckerDTO is DTO for NewChecker
type CheckerStruct ¶
type CheckerStruct struct { RandomRCPT SendMailFactory SendMailDialerFactory Auth smtp.Auth RandomEmail RandomEmail Options Options }
CheckerStruct some SMTP server send additional message and we should read it 2.1.5 for OK message
type CheckerWithRandomRCPT ¶
type CheckerWithRandomRCPT interface { Checker RandomRCPT }
CheckerWithRandomRCPT is used for caching of RandomRCPT
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 InputStruct ¶
func (*InputStruct) Email ¶
func (i *InputStruct) Email() evmail.Address
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
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 OptionsStruct ¶
type OptionsStruct struct { EmailFromOption evmail.Address HelloNameOption string ProxyOption string TimeoutConOption time.Duration TimeoutRespOption time.Duration PortOption int }
func (*OptionsStruct) EmailFrom ¶
func (i *OptionsStruct) EmailFrom() evmail.Address
func (*OptionsStruct) HelloName ¶
func (i *OptionsStruct) HelloName() string
func (*OptionsStruct) Port ¶
func (i *OptionsStruct) Port() int
func (*OptionsStruct) Proxy ¶
func (i *OptionsStruct) Proxy() string
func (*OptionsStruct) TimeoutConnection ¶
func (i *OptionsStruct) TimeoutConnection() time.Duration
func (*OptionsStruct) TimeoutResponse ¶
func (i *OptionsStruct) TimeoutResponse() time.Duration
type RandomCacheKeyGetter ¶
RandomCacheKeyGetter is type of function to Get cache key
type RandomEmail ¶
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 Set(fn RandomRCPTFunc) Get() RandomRCPTFunc }
RandomRCPT Need to realize of is-a relation (inheritance)
type RandomRCPTFunc ¶
RandomRCPTFunc is function for checking of Catching All
type SafeSendMailStage ¶
type SafeSendMailStage struct { SendMailStage // contains filtered or unexported fields }
SafeSendMailStage is thread safe SendMailStage
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 ¶
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
type SendMailStruct ¶
type SendMailStruct struct { SMTPClient smtpclient.SMTPClient TLSConfig *tls.Config }
func (*SendMailStruct) Client ¶
func (s *SendMailStruct) Client() smtpclient.SMTPClient
func (*SendMailStruct) Close ¶
func (s *SendMailStruct) Close() error
func (*SendMailStruct) Data ¶
func (s *SendMailStruct) Data() (io.WriteCloser, error)
func (*SendMailStruct) Hello ¶
func (s *SendMailStruct) Hello(helloName string) error
func (*SendMailStruct) Mail ¶
func (s *SendMailStruct) Mail(from string) error
func (*SendMailStruct) Quit ¶
func (s *SendMailStruct) Quit() error
func (*SendMailStruct) Write ¶
func (s *SendMailStruct) Write(w io.WriteCloser, msg []byte) error