Documentation
¶
Overview ¶
Package mail is iterion's minimal transactional mailer: stdlib SMTP (explicit STARTTLS) + embedded templates for the two flows that need email — invitations and password resets. No third-party dependency by design.
When SMTP isn't configured the LogMailer stands in: flows still mint their tokens and the would-be email lands in the logs (handy for local dev and tests). The server exposes `email_enabled` on /api/server/info so the SPA only offers email-dependent flows (forgot-password) when a real mailer is wired.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Host string
Port int
Username string
Password string
// From is the envelope + header sender, e.g. "iterion <no-reply@example.org>".
From string
// StartTLS upgrades the connection before AUTH (default true).
// Disabling it is only sane against a localhost relay.
StartTLS bool
// Timeout bounds the whole SMTP conversation (default 10s).
Timeout time.Duration
}
Config is the SMTP transport configuration (ITERION_SMTP_* env in the server bootstrap; helm `config.smtp.*` + `secrets.smtp`).
type InviteData ¶
type InviteData struct {
TeamName string
Role string
// AcceptURL is the SPA link carrying the invitation token.
AcceptURL string
// InvitedBy is a display hint (email of the inviting admin).
InvitedBy string
}
InviteData parameterises the invitation email.
type LogMailer ¶
LogMailer is the no-SMTP fallback: the email is written to the logger (token links included) so local-dev flows stay testable. Enabled() is false — the SPA hides email-dependent entry points.
type Mailer ¶
type Mailer interface {
Send(ctx context.Context, m Message) error
// Enabled reports whether sends actually leave the process —
// false for the log fallback. Drives `email_enabled` in
// server_info.
Enabled() bool
}
Mailer sends transactional email.
type Message ¶
Message is one outbound transactional email. Both bodies are provided; the MIME envelope is multipart/alternative.
func RenderInvitation ¶
func RenderInvitation(to string, d InviteData) Message
RenderInvitation builds the team-invitation message for `to`.
func RenderPasswordReset ¶
RenderPasswordReset builds the password-reset message for `to`.
type ResetData ¶
type ResetData struct {
// ResetURL is the SPA link carrying the one-shot token, e.g.
// https://iterion.example.org/auth/reset?token=iar_…
ResetURL string
// ExpiresMinutes is the token lifetime for the copy.
ExpiresMinutes int
}
ResetData parameterises the password-reset email.
type SMTPMailer ¶
type SMTPMailer struct {
// contains filtered or unexported fields
}
SMTPMailer sends via stdlib SMTP with an explicit STARTTLS upgrade. Deliberately NOT smtp.SendMail: the wrapper silently skips AUTH on a plaintext session, which would post credentials-less mail or leak nothing at all depending on the relay — explicit client calls make the TLS-before-AUTH ordering auditable.
func NewSMTP ¶
func NewSMTP(cfg Config) (*SMTPMailer, error)
NewSMTP validates the config and returns the mailer.
func (*SMTPMailer) Enabled ¶
func (s *SMTPMailer) Enabled() bool