mail

package
v0.72.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package mail sends the outbox: a Mailer drains queued mail through a Sender, either SMTP or a Log sender for development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	Out io.Writer
	// contains filtered or unexported fields
}

Log writes each mail to Out instead of sending it, so a dev server prints sign-in codes where the operator can read them.

func (*Log) Send

func (l *Log) Send(_ context.Context, m core.Mail) error

type Mailer

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

Mailer drains the outbox through a Sender.

func NewMailer

func NewMailer(log zerolog.Logger, outbox core.OutboxStore, sender Sender, now func() time.Time) *Mailer

NewMailer returns a Mailer. A nil now means time.Now.

func (*Mailer) Drain

func (m *Mailer) Drain(ctx context.Context) error

Drain sends every due mail once. A send failure defers that mail and does not stop the pass.

func (*Mailer) Run

func (m *Mailer) Run(ctx context.Context, every time.Duration) error

Run drains every interval until ctx is done. A failed pass is logged and the loop continues.

type SMTP

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

SMTP sends through one server. smtp:// upgrades with STARTTLS and refuses a server that does not offer it, except on loopback, where a local catcher such as Mailpit speaks plain SMTP. smtps:// is TLS from the first byte. Without a user in the URL, the client does not authenticate.

func NewSMTP

func NewSMTP(rawURL, password, from string) (*SMTP, error)

NewSMTP parses rawURL (smtp://user@host:587 or smtps://user@host:465; the port defaults by scheme). password is sent only when the URL names a user.

func (*SMTP) Send

func (s *SMTP) Send(ctx context.Context, m core.Mail) error

type Sender

type Sender interface {
	Send(ctx context.Context, m core.Mail) error
}

Jump to

Keyboard shortcuts

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