mailer

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(account Account) (*mailer, error)

New returns a new mailer that sends mail through account.

func PrepareTemplate

func PrepareTemplate[T tmpl.Context](ctx context.Context, cfg config.Config, engine *tmpl.Engine, email Message, template tmpl.Known[T], args T) (*mail.Message, error)

func SendTemplate

func SendTemplate[T tmpl.Context](ctx context.Context, cfg config.Config, engine *tmpl.Engine, m Mailer, email Message, template tmpl.Known[T], args T) error

Types

type Account

type Account struct {
	// Host should holds the SMPT host name the mailer should
	// use to send mails.
	Host string
	// Port should holds the SMTP port the host is listening on.
	Port int
	// Username required for authentication.
	Username string
	// Password required for authentication.
	Password string
	// From defines the default sender to use for this account.
	From string
	// AllowInsecure can be set to true to disable TLS certificate
	// verification.
	AllowInsecure bool
	// UseSSL can be set to either true or false to force SSL to be enabled
	// or disabled. If not configured, SSL will be used for the default
	// SSL port.
	UseSSL *bool
}

type Mailer

type Mailer interface {
	DialAndSend(...*mail.Message) error
}

type Message

type Message struct {
	From string
	To   []string
	Cc   []string
	Bcc  []string
}

type NoOpMailer

type NoOpMailer struct{}

func (*NoOpMailer) DialAndSend

func (*NoOpMailer) DialAndSend(...*mail.Message) error

Jump to

Keyboard shortcuts

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