Documentation
¶
Overview ¶
Package mail delivers team emails (magic-link logins). It exposes a small Mailer interface with two implementations: an SMTP mailer for real delivery and a log mailer for local development, which prints the message (including the magic link) to the logger so the flow can be exercised without any SMTP configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogMailer ¶
LogMailer logs messages instead of sending them. It is the default when no SMTP host is configured, so local/dev deployments can complete the magic-link flow by reading the link from the logs.
func NewLogMailer ¶
NewLogMailer creates a LogMailer.
type MagicLinkData ¶
type MagicLinkData struct {
// AppName is shown in the email (e.g. the team/agent name).
AppName string
// Link is the full verify URL the recipient clicks.
Link string
// TTL is how long the link remains valid.
TTL time.Duration
}
MagicLinkData is the content for a magic-link email.
type Message ¶
Message is an outbound email.
func MagicLinkMessage ¶
func MagicLinkMessage(to string, d MagicLinkData) Message
MagicLinkMessage renders the login email for a recipient.
type SMTPConfig ¶
type SMTPConfig struct {
Host string
Port int
Username string
Password string
// From is the envelope/header sender address.
From string
}
SMTPConfig configures the SMTP mailer.
type SMTPMailer ¶
type SMTPMailer struct {
// contains filtered or unexported fields
}
SMTPMailer delivers email over SMTP.
func NewSMTPMailer ¶
func NewSMTPMailer(cfg SMTPConfig) (*SMTPMailer, error)
NewSMTPMailer creates an SMTP mailer. TLS is mandatory when a port is given (STARTTLS on 587 / implicit on 465 are handled by go-mail's port policy); auth is auto-discovered, or disabled when no username is set (common for relay-on-localhost setups).