smtp

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorParamsEmpty errors.CodeError = iota + errors.MinPkgSMTP
	ErrorConfigInvalidDSN
	ErrorConfigInvalidNetwork
	ErrorConfigInvalidParams
	ErrorConfigInvalidHost
	ErrorSMTPDial
	ErrorSMTPClientInit
	ErrorSMTPClientStartTLS
	ErrorSMTPClientAuth
	ErrorSMTPClientNoop
	ErrorSMTPClientMail
	ErrorSMTPClientRcpt
	ErrorSMTPClientData
	ErrorSMTPClientWrite
	ErrorSMTPLineCRLF
)

Variables

This section is empty.

Functions

func IsCodeError

func IsCodeError() bool

Types

type Config added in v1.5.4

type Config interface {
	SetHost(host string)
	GetHost() string

	SetPort(port int)
	GetPort() int

	SetUser(user string)
	GetUser() string

	SetPass(pass string)
	GetPass() string

	SetNet(mode NETMode)
	GetNet() NETMode

	SetTls(mode TLSMode)
	GetTls() TLSMode

	ForceTLSSkipVerify(skip bool)
	IsTLSSkipVerify() bool

	SetTLSServerName(serverName string)
	GetTlSServerName() string

	GetDsn() string
}

func NewConfig added in v1.5.4

func NewConfig(dsn string) (Config, errors.Error)

NewConfig parses the DSN string to a Config. nolint: gocognit

type ConfigModel added in v1.8.1

type ConfigModel struct {
	DSN string        `json:"dsn" yaml:"dsn" toml:"dsn" mapstructure:"dsn"`
	TLS libtls.Config `json:"tls,omitempty" yaml:"tls,omitempty" toml:"tls,omitempty" mapstructure:"tls,omitempty"`
}

func (ConfigModel) SMTP added in v1.8.1

func (c ConfigModel) SMTP(tlsDefault libtls.TLSConfig) (SMTP, liberr.Error)

type NETMode

type NETMode uint8
const (
	NET_TCP NETMode = iota
	NET_TCP_4
	NET_TCP_6
	NET_UNIX
)

type SMTP

type SMTP interface {
	Client(ctx context.Context) (*smtp.Client, errors.Error)
	Close()
	Check(ctx context.Context) errors.Error
	Clone() SMTP
	Send(ctx context.Context, from string, to []string, data io.WriterTo) errors.Error
}

func NewSMTP

func NewSMTP(cfg Config, tlsConfig *tls.Config) (SMTP, errors.Error)

NewSMTP return a SMTP interface to operation negotiation with a SMTP server. the dsn parameter must be string like this '[user[:password]@][net[(addr)]]/tlsmode[?param1=value1&paramN=valueN]".

  • params available are : ServerName (string), SkipVerify (boolean).
  • tls mode acceptable are : starttls, tls, <any other value to no tls/startls>.
  • net aceeptable are : tcp4, tcp6, unix.

type TLSMode

type TLSMode uint8
const (
	TLS_NONE TLSMode = iota
	TLS_STARTTLS
	TLS_TLS
)

Jump to

Keyboard shortcuts

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