smtp

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorParamsEmpty errors.CodeError = iota + errors.MinPkgSMTP
	ErrorConfigValidator
	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

	SetTlsMode(mode TLSMode)
	GetTlsMode() TLSMode

	SetTls(tls libtls.Config)
	GetTls() libtls.Config

	ForceTLSSkipVerify(skip bool)
	IsTLSSkipVerify() bool

	SetTLSServerName(serverName string)
	GetTlSServerName() string

	SetStatusConfig(sts libsts.ConfigStatus)
	GetStatusConfig() libsts.ConfigStatus

	GetDsn() string
}

func NewConfig added in v1.5.4

func NewConfig(cfg ConfigModel) (Config, liberr.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"`
	Status libsts.ConfigStatus `json:"status,omitempty" yaml:"status,omitempty" toml:"status,omitempty" mapstructure:"status,omitempty"`
	// contains filtered or unexported fields
}

func (ConfigModel) GetSMTP added in v1.8.10

func (c ConfigModel) GetSMTP() (SMTP, liberr.Error)

func (ConfigModel) RegisterDefaultTLS added in v1.8.10

func (c ConfigModel) RegisterDefaultTLS(fct func() libtls.TLSConfig)

func (ConfigModel) SMTP added in v1.8.1

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

func (ConfigModel) Validate added in v1.8.10

func (c ConfigModel) Validate() 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 {
	Clone() SMTP
	Close()

	Client(ctx context.Context) (*smtp.Client, liberr.Error)
	Check(ctx context.Context) liberr.Error
	Send(ctx context.Context, from string, to []string, data io.WriterTo) liberr.Error

	StatusInfo() (name string, release string, hash string)
	StatusHealth() error
	StatusRouter(sts libsts.RouteStatus, prefix string)
}

func NewSMTP

func NewSMTP(cfg Config, tlsConfig *tls.Config) (SMTP, liberr.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