email

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDriverRequired = errors.New("email: driver is required")
	ErrUnknownDriver  = errors.New("email: unknown driver")
)

Functions

func RegisterDriver

func RegisterDriver(driver string, factory DriverFactory)

Types

type AttemptResult

type AttemptResult struct {
	Provider string
	Success  bool
	Result   *ProviderResult
	Error    error
}

type DriverFactory

type DriverFactory func(name string, cfg ProviderConfig) (Provider, error)

type Message

type Message struct {
	To      []string
	Cc      []string
	Bcc     []string
	Subject string
	Text    string
	HTML    string
	Headers map[string]string
}

type Middleware

type Middleware func(Sender) Sender

type Provider

type Provider interface {
	Send(ctx context.Context, msg Message) (*ProviderResult, error)
	Close() error
}

func NewProvider

func NewProvider(name string, cfg ProviderConfig) (Provider, error)

type ProviderConfig

type ProviderConfig struct {
	Driver      string        `mapstructure:"driver" yaml:"driver"`
	Host        string        `mapstructure:"host" yaml:"host"`
	Port        int           `mapstructure:"port" yaml:"port"`
	Username    string        `mapstructure:"username" yaml:"username"`
	Password    string        `mapstructure:"password" yaml:"password"`
	FromAddress string        `mapstructure:"from_address" yaml:"from_address"`
	FromName    string        `mapstructure:"from_name" yaml:"from_name"`
	ReplyTo     string        `mapstructure:"reply_to" yaml:"reply_to"`
	Encryption  string        `mapstructure:"encryption" yaml:"encryption"`
	Auth        string        `mapstructure:"auth" yaml:"auth"`
	Timeout     time.Duration `mapstructure:"timeout" yaml:"timeout"`
}

func (ProviderConfig) Clone

func (c ProviderConfig) Clone() ProviderConfig

type ProviderResult

type ProviderResult struct {
	MessageID string
	Raw       any
}

type Request

type Request struct {
	Message   Message
	Providers []string
}

type SendResult

type SendResult struct {
	Provider string
	Attempts []AttemptResult
}

type Sender

type Sender interface {
	Send(ctx context.Context, req Request) (*SendResult, error)
}

type SenderFunc

type SenderFunc func(ctx context.Context, req Request) (*SendResult, error)

func (SenderFunc) Send

func (fn SenderFunc) Send(ctx context.Context, req Request) (*SendResult, error)

Directories

Path Synopsis
driver

Jump to

Keyboard shortcuts

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