smtp

package
v0.0.0-...-b595bbb Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSMTPClient   = errors.New("no SMTP client provided") // no SMTP client provided
	ErrAuthFailed     = errors.New("authentication failed")   // authentication failed
	ErrComposeEmail   = errors.New("failed to compose email") // failed to compose email
	ErrNoBytesWritten = errors.New("no bytes written")        // no bytes written
)

Functions

This section is empty.

Types

type Client

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

Client is the simplified SMTP client used for sending notification emails.

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient returns a new Client.

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context) error

Authenticate initiates the SMTP handshake and authenticates the client.

func (*Client) SendEmail

func (c *Client) SendEmail(ctx context.Context, subject, to string, template *email.Template) error

SendEmail sends an email with the given subject and body to the recipient.

type Option

type Option func(*Client) error

Option is a function that configures a Client.

func WithConfig

func WithConfig(cfg *config.SMTPConfig) Option

WithConfig returns an Option that configures a Client with the given configuration.

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger returns an Option that configures a Client with the given logger.

func WithTracer

func WithTracer(tracer tracing.Tracer) Option

WithTracer returns an Option that configures a Client with the given tracer.

func WithWrappedClient

func WithWrappedClient(wrapped WrappedClient) Option

WithWrappedClient returns an Option that configures a Client with the given wrapped SMTP client. The given SMTP client is used as a base that is configured.

type WrappedClient

type WrappedClient interface {
	Close() error
	Hello(localName string) error
	StartTLS(config *tls.Config) error
	TLSConnectionState() (state tls.ConnectionState, ok bool)
	Verify(addr string) error
	Auth(a smtp.Auth) error
	Mail(from string) error
	Rcpt(to string) error
	Data() (io.WriteCloser, error)
	Extension(ext string) (bool, string)
	Reset() error
	Noop() error
	Quit() error
}

WrappedClient is the interface that wraps the SMTP client methods used by the Client.

Jump to

Keyboard shortcuts

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