email

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package email sends notification batches over implicit-TLS SMTP.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidConfig indicates invalid transport or destination settings.
	ErrInvalidConfig = errors.New("invalid email configuration")
	// ErrInvalidAddress indicates an invalid envelope address.
	ErrInvalidAddress = errors.New("invalid email address")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Host          string
	Port          string
	Username      string
	Password      string
	From          string
	TLSServerName string

	// TLSConfig overrides the default TLS configuration (TLS 1.2 minimum). NewTransport clones it.
	TLSConfig *tls.Config
}

Config defines SMTP settings. All fields except TLSServerName and TLSConfig are required; From does not default to Username.

type Message

type Message struct {
	Subject string
	Text    string
	HTML    string
}

Message contains rendered email content.

type Renderer

type Renderer[T any] func(batch []T) Message

Renderer renders a notification batch as email content.

type Transport

type Transport[T any] struct {
	// contains filtered or unexported fields
}

Transport is an immutable SMTP client shared safely by concurrent destinations.

func NewTransport

func NewTransport[T any](cfg Config) (*Transport[T], error)

NewTransport validates cfg and creates a Transport without network I/O.

func (*Transport[T]) Recipient

func (transport *Transport[T]) Recipient(
	id string,
	address string,
	renderer Renderer[T],
) (notifier.Destination[T], error)

Recipient creates a destination for one SMTP recipient.

func (*Transport[T]) RecipientGroup

func (transport *Transport[T]) RecipientGroup(
	id string,
	addresses []string,
	renderer Renderer[T],
) (notifier.Destination[T], error)

RecipientGroup creates a destination that sends to all addresses in one SMTP transaction.

Jump to

Keyboard shortcuts

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