mail

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: ISC Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func NewClient

func NewClient(host, user, password, emailAddress, certPath string, skipVerify bool, rateLimit int, db user.MailerDB) (*client, error)

NewClient returns a new client.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type Mailer

type Mailer interface {
	// IsEnabled determines if the smtp server is enabled or not.
	IsEnabled() bool

	// SendTo sends an email to a list of recipient email addresses.
	// This function does not rate limit emails and a recipient does
	// does not need to correspond to a politeiawww user. This function
	// can be used to send emails to sysadmins or similar cases.
	SendTo(subject, body string, recipients []string) error

	// SendToUsers sends an email to a list of recipient email
	// addresses. The recipient MUST correspond to a politeiawww user
	// in the database for the email to be sent. This function rate
	// limits the number of emails that can be sent to any individual
	// user over a 24 hour period. If a recipient is provided that does
	// not correspond to a politeiawww user, the email is simply
	// skipped. An error is not returned.
	SendToUsers(subject, body string, recipients map[uuid.UUID]string) error
}

Mailer provides an API for interacting with the smtp server.

Jump to

Keyboard shortcuts

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