Documentation
¶
Overview ¶
Package mail sends transactional email (account confirmation) over SMTP. It is intentionally tiny: standard net/smtp with STARTTLS, configured from AGENTBBS_SMTP_* env vars. When unconfigured, Configured() reports false and the caller logs the confirmation link instead of sending it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Host string // smtp server host (no port)
Port string // default 587 (STARTTLS)
User string // auth user; empty = no auth
Pass string
From string // envelope + From: header
// ServerName is the name STARTTLS certificates are verified against when it
// differs from Host. A co-located relay is dialled on loopback but presents a
// certificate for its public mail host, never for 127.0.0.1. Mirrors
// AGENTBBS_MAIL_SMTP_SERVERNAME on the mailbox gateway.
ServerName string
}
Config is an SMTP relay. Host+From are the minimum for Configured().
func ConfigFromEnv ¶
func ConfigFromEnv() Config
ConfigFromEnv reads AGENTBBS_SMTP_{HOST,PORT,USER,PASS,FROM,SERVERNAME}.
func (Config) Configured ¶
Configured reports whether email can actually be sent.
func (Config) Send ¶
Send delivers a plain-text message. STARTTLS is negotiated whenever the server advertises it (the common case on :587 and on a co-located :25). Implicit-TLS :465 is not supported — use a STARTTLS port.
Certificates are verified against tlsServerName() EXCEPT on a loopback relay, where verification is skipped deliberately. An on-box MTA serves a cert for its public mail host and renews it on its own schedule; making join@ signups depend on that cert being both name-matched and unexpired is how registration silently died for nine days when the Mailu cert lapsed. Loopback traffic is not interceptable, so the check bought nothing and cost everything.