mail

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBackend = "default"
)

Variables

View Source
var (
	ErrConfigNil       = errors.New("config is nil")
	ErrBackendNotFound = errors.New("backend not found")
)

Functions

func Close

func Close[T string | interface{}](backendOrName T) error

func PlainAuth

func PlainAuth(identity, username, password, host string) smtp.Auth

func Register

func Register(name string, backend EmailBackend)

func Send

func Send(e *email.Email, backendOrName ...interface{}) error

func SetDefault

func SetDefault(backend EmailBackend)

func Unregister

func Unregister(name string)

func XOAuth2Auth

func XOAuth2Auth(username, token string) smtp.Auth

Types

type Config

type Config struct {
	Host        string        // Mail server host.
	Port        int           // Mail server port.
	Username    string        // Mail server username.
	Password    string        // Mail server password.
	UseTLS      bool          // USE_TLS
	UseSSL      bool          // USE_SSL
	MailFrom    string        // Mail server from address.
	Timeout     time.Duration // Timeout duration for sending email.
	TLSConfig   *tls.Config   // TLS Config
	DefaultAuth smtp.Auth     // Default SMTP Auth
}

func (*Config) Next

func (m *Config) Next(fromServer []byte, more bool) ([]byte, error)

func (*Config) Start

func (m *Config) Start(server *smtp.ServerInfo) (string, []byte, error)

type EmailBackend

type EmailBackend interface {
	Send(e *email.Email) error
}

func Default

func Default() EmailBackend

func Get

func Get(name string) EmailBackend

func NewConsoleBackend

func NewConsoleBackend(f io.Writer) EmailBackend

func NewPooledEmailBackend

func NewPooledEmailBackend(poolCount int, cnf *Config) (EmailBackend, error)

type OpenableEmailBackend

type OpenableEmailBackend interface {
	Open() error
	IsOpen() bool
	Close() error
}

Jump to

Keyboard shortcuts

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