mailer

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingSender    = fmt.Errorf("sender address missing")
	ErrMissingRecipient = fmt.Errorf("recipient address missing")
)

Functions

func LoadCACert added in v0.3.2

func LoadCACert(path string) (*x509.CertPool, error)

Types

type AmazonSESMailer

type AmazonSESMailer struct {
	From    string `mapstructure:"from"`
	To      string `mapstructure:"to"`
	Region  string `mapstructure:"region"`
	Session *sesv2.SESV2
	Logger  *log.Logger
}

AmazonSESMailer represents a mail sender for Amazon SES.

func (AmazonSESMailer) Init

func (s AmazonSESMailer) Init() error

Init implements the Mailer's Init interface.

func (AmazonSESMailer) Send

func (s AmazonSESMailer) Send(subject, body string) error

Send implements the Mailer's Send interface.

type Mailer

type Mailer interface {
	Init() error
	Send(subject, body string) error
}

Mailer is a generic interface for mail senders.

type NoOpMailer added in v0.3.0

type NoOpMailer struct{}

NoOpMailer is a dummy mailer that doesn't send mail.

func (NoOpMailer) Init added in v0.3.0

func (m NoOpMailer) Init() error

Init implements the Mailer's Init interface.

func (NoOpMailer) Send added in v0.3.0

func (m NoOpMailer) Send(_, _ string) error

Send implements the Mailer's Send interface.

type SMTPMailer

type SMTPMailer struct {
	From              string `mapstructure:"from"`
	To                string `mapstructure:"to"`
	Server            string `mapstructure:"server"`
	Port              int    `mapstructure:"port"`
	Username          string `mapstructure:"username"`
	Password          string `mapstructure:"password"`
	CaCert            string `mapstructure:"ca_cert_file"`
	RequireEncryption bool   `mapstructure:"require_encryption"`
}

SMTPMailer represents a mail sender for plain SMTP.

func (SMTPMailer) Init

func (s SMTPMailer) Init() error

Init implements the Mailer's Init interface.

func (SMTPMailer) Send

func (s SMTPMailer) Send(subject, body string) error

Send implements the Mailer's Send interface.

type SendgridMailer

type SendgridMailer struct {
	From   string `mapstructure:"from"`
	To     string `mapstructure:"to"`
	APIKey string `mapstructure:"token"`
	Client *sendgrid.Client
	Logger *log.Logger
}

SendgridMailer represents a mail sender for sendgrid.

func (*SendgridMailer) Init

func (s *SendgridMailer) Init(from, to string) error

Init implements the Mailer's Init interface.

func (SendgridMailer) Send

func (s SendgridMailer) Send(subject, body string) error

Send implements the Mailer's Send interface.

Jump to

Keyboard shortcuts

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