smtpx

package
v0.192.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: AGPL-3.0, AGPL-3.0-or-later Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultShouldRetry added in v0.115.0

func DefaultShouldRetry(err error) bool

DefaultShouldRetry is the default function for determining if a send should be retried

func Send

func Send(c *Client, m *Message, retries *RetryConfig) error

Send an email using SMTP

func SetSender

func SetSender(sender Sender)

SetSender sets the sender used by Send

Types

type Client added in v0.104.0

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

Client is an SMTP client

func NewClient added in v0.104.0

func NewClient(host string, port int, username, password, from string) *Client

NewClient creates a new client

func NewClientFromURL added in v0.104.0

func NewClientFromURL(connectionURL string) (*Client, error)

NewClientFromURL creates a client from a URL like smtp://user:pass@host:port/?from=from@example.com

func (*Client) Send added in v0.104.0

func (c *Client) Send(m *Message) error

Send sends the given message

type Message added in v0.104.0

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

Message is email message

func NewMessage added in v0.104.0

func NewMessage(recipients []string, subject, text, html string) *Message

NewMessage creates a new message

type MockSender

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

MockSender is a mocked sender for testing that just logs would-be commands

func NewMockSender

func NewMockSender(errs ...error) *MockSender

NewMockSender creates a new mock sender

func (*MockSender) Logs

func (s *MockSender) Logs() []string

Logs returns the send logs

func (*MockSender) Send

func (s *MockSender) Send(c *Client, m *Message) error

type RetryConfig added in v0.115.0

type RetryConfig struct {
	Backoffs    []time.Duration
	ShouldRetry func(error) bool
}

RetryConfig configures if and how retrying of connections happens

func NewFixedRetries added in v0.115.0

func NewFixedRetries(backoffs ...time.Duration) *RetryConfig

NewFixedRetries creates a new retry config with the given backoffs

func (*RetryConfig) Backoff added in v0.115.0

func (r *RetryConfig) Backoff(n int) time.Duration

Backoff gets the backoff time for the nth retry

func (*RetryConfig) MaxRetries added in v0.115.0

func (r *RetryConfig) MaxRetries() int

MaxRetries gets the maximum number of retries allowed

type Sender

type Sender interface {
	Send(*Client, *Message) error
}

Sender is anything that can send an email

var DefaultSender Sender = defaultSender{}

DefaultSender is the default SMTP sender

Jump to

Keyboard shortcuts

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