mailer

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: BSD-3-Clause Imports: 5 Imported by: 2

Documentation

Overview

Package mailer sends emails via gmail asynchronously.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Email

type Email struct {
	To      []string
	Subject string
	Body    string
}

Email represents a single email.

type Mailer

type Mailer struct {
	// contains filtered or unexported fields
}

Mailer sends emails asynchronously via gmail.

func New

func New(emailId, password string) *Mailer

New creates a new instance. emailId and password are the gmail sender address and password respectively. The created Mailer has a buffer size of 100 and a send wait time of 1s.

func NewWithOptions added in v0.14.0

func NewWithOptions(emailId, password string, options ...Option) *Mailer

NewWithOptions works like New, but allows creation to be configured with options. The defaults for each option are the same as New.

func (*Mailer) Send

func (m *Mailer) Send(email Email)

Send sends one email asynchronously returning immediately. When it eventually sends the email, it reports any errors to stderr.

func (*Mailer) SendFuture added in v0.13.0

func (m *Mailer) SendFuture(email Email) <-chan error

SendFuture sends one email asynchronously returning immediately. Caller must use returned channel to get the result of the send.

func (*Mailer) Shutdown added in v0.13.0

func (m *Mailer) Shutdown()

Shutdown shuts down this mailer. Shutdown waits to return until all pending emails have been sent. It is an error to call Send or SendFuture after calling Shutdown.

type Option added in v0.14.0

type Option interface {
	// contains filtered or unexported methods
}

Option represents an option for the NewWithOptions method.

func BufferSize added in v0.14.0

func BufferSize(bufferSize int) Option

BufferSize sets the maximum number of pending emails before Send or SendFuture block.

func SendWaitTime added in v0.14.0

func SendWaitTime(timeToWait time.Duration) Option

SendWaitTime sets the time to wait between email sends.

Jump to

Keyboard shortcuts

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