mailer

package
v3.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package mailer provides email sending over a pluggable transport (SMTP, in-memory) with RFC 5322 / MIME rendering.

Index

Constants

View Source
const ServiceMailer = "service.mailer.mailer"

Variables

This section is empty.

Functions

func MailerMustFromContainer

func MailerMustFromContainer(serviceContainer containercontract.Container) mailercontract.Mailer

func MailerMustFromResolver

func MailerMustFromResolver(resolver containercontract.Resolver) mailercontract.Mailer

func RenderMessage

func RenderMessage(message mailercontract.Message) ([]byte, error)

Types

type InMemoryTransport

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

func NewInMemoryTransport

func NewInMemoryTransport() *InMemoryTransport

func (*InMemoryTransport) Send

func (instance *InMemoryTransport) Send(runtimeInstance runtimecontract.Runtime, message mailercontract.Message) error

func (*InMemoryTransport) Sent

func (instance *InMemoryTransport) Sent() []mailercontract.Message

type LogTransport added in v3.8.0

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

func NewLogTransport added in v3.8.0

func NewLogTransport(logger loggingcontract.Logger) *LogTransport

@info LogTransport writes the recipients (To, Cc, Bcc), subject, both the text and HTML bodies, and per-attachment metadata of every message to the logger instead of delivering it; intended for local development so a misconfigured app never sends real mail

func (*LogTransport) Send added in v3.8.0

func (instance *LogTransport) Send(runtimeInstance runtimecontract.Runtime, message mailercontract.Message) error

@info the logger supplied at construction is preferred; when it is nil the request-scoped logger is resolved quietly from the runtime (a missing logger service is swallowed rather than emitting an emergency log on every send), and when neither is available the send is a safe no-op

type Manager

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

func NewManager

func NewManager(transport mailercontract.Transport) *Manager

func (*Manager) Send

func (instance *Manager) Send(runtimeInstance runtimecontract.Runtime, message mailercontract.Message) error

type SmtpConfig

type SmtpConfig struct {
	Address     string
	Host        string
	Username    string
	Password    string
	RequireTls  bool
	RequireAuth bool
	ImplicitTls bool
	TlsConfig   *tls.Config

	/* DialTimeout bounds the tcp connect, the tls handshake and the server's opening greeting; zero selects defaultSmtpDialTimeout. A server that accepts the connection and then never speaks would otherwise block the sending goroutine and hold the socket forever. */
	DialTimeout time.Duration

	/* Timeout bounds every step of the smtp session after the greeting — the hello, auth, the mail/rcpt/data commands, each chunk of the payload write and the quit — by resetting a per-step deadline before each one; a step is one client call, so the STARTTLS upgrade (command, tls handshake and the hello the client repeats over tls) counts as a single step. The payload is written in fixed-size chunks with the deadline re-armed per chunk, so the ceiling measures progress rather than total transfer time: a large message on a slow-but-alive link completes regardless of its size, while a stalled peer still fails within one Timeout. Zero falls back to DialTimeout, then to defaultSmtpDialTimeout. The greeting only bounds the opening handshake, so a relay that greets promptly then stalls mid-conversation (overloaded, a firewall black-holing traffic after the handshake, a slow-loris on DATA) would otherwise pin the sending goroutine and its socket indefinitely — which matters most when mail is sent inline from a request handler. */
	Timeout time.Duration

	/* DataTerminationTimeout bounds the server's acknowledgment of the message-ending dot — the one reply a relay routinely delays far beyond any other while it runs content inspection and spam scoring; rfc 5321 allows it up to ten minutes. A ceiling as tight as the per-step Timeout would turn a scanning relay into an error after the message may already be queued, inviting a retry and a duplicate delivery. Zero derives four times the resolved per-step Timeout, raised to at least two minutes. */
	DataTerminationTimeout time.Duration
}

type SmtpTransport

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

func NewSmtpTransport

func NewSmtpTransport(config SmtpConfig) *SmtpTransport

func (*SmtpTransport) Send

func (instance *SmtpTransport) Send(runtimeInstance runtimecontract.Runtime, message mailercontract.Message) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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