mailer

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package mailer sends plain-text e-mail through an SMTP server. It exists for password reset links and nothing else, so it stays small: one message, one recipient, text only.

Index

Constants

View Source
const (
	StartTLS = "starttls" // plain connection upgraded with STARTTLS, usually port 587
	TLS      = "tls"      // TLS from the first byte, usually port 465
	None     = "none"     // no encryption: only accepted for a server on this machine
)

Transport security modes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string
	Port     int
	Username string // empty: no authentication
	Password string
	From     string // address, optionally with a display name
	TLS      string // StartTLS (default), TLS or None
	// DialControl, when set, is the Control function of the connection's dialer: it sees the address
	// the host name resolved to, before the connection is made, and may refuse it.
	DialControl func(network, address string, c syscall.RawConn) error
}

Config describes the SMTP server and the sender address.

type SMTP

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

SMTP sends through an SMTP server.

func New

func New(cfg Config) (*SMTP, error)

New checks the configuration. It does not connect.

func (*SMTP) Send

func (m *SMTP) Send(ctx context.Context, to, subject, body string) error

Send delivers the message. The recipient must be a plain address (no name, no line breaks).

type Sender

type Sender interface {
	Send(ctx context.Context, to, subject, body string) error
}

Sender sends one message to one recipient.

Jump to

Keyboard shortcuts

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