Documentation
¶
Overview ¶
Package mail sends glabs-web's job-notification emails. It keeps the go-mail dependency and the Markdown→text+HTML rendering confined here, so callers deal only with a small library-neutral surface (Config, Sender, Render, JobMail).
Every notification renders from a single Markdown template into both a text and an HTML part, so the two can never drift. SMTP credentials live in the server config file, never in the database.
Index ¶
Constants ¶
const ( TmplScheduled = "jobScheduled.md.tmpl" TmplDone = "jobDone.md.tmpl" TmplFailed = "jobFailed.md.tmpl" TmplExpired = "jobExpired.md.tmpl" TmplAdminSummary = "adminSummary.md.tmpl" )
Template file names for the four job-notification mails and the admin summary.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render renders the named Markdown template with data into the plain-text part (the Markdown itself, readable as-is, plus a footer) and the HTML part (Markdown → HTML wrapped in the shared base layout). One source feeds both, so they cannot drift. missingkey=error turns a template referencing an unknown field into an error instead of silently emitting "<no value>".
Types ¶
type Config ¶
type Config struct {
Host string
Port int
Username string
Password string
// From is the address mails are sent as (the From header and, by default, the
// SMTP envelope sender). Required.
From string
// Hostname is the FQDN used for the SMTP HELO/EHLO greeting and the Message-ID
// domain. Empty falls back to defaultMailHostname; strict servers reject a
// Message-ID derived from a container's os.Hostname().
Hostname string
// TLSInsecureSkipVerify disables server-certificate verification. Unlike
// plexams (which hard-codes skip), this defaults to false — verify.
TLSInsecureSkipVerify bool
// TestRecipient receives dry-run sends and SendTest smoke tests.
TestRecipient string
}
Config is the SMTP configuration, read from the server config in bootstrap. It is passed to NewSender; the mail package itself never touches viper.
type JobMail ¶
type JobMail struct {
Op string
Course string
Assignment string
RunAt time.Time
GraceMin int
// Err is set for the failed/expired mails; Log carries the captured run output.
Err string
Log string
}
JobMail is the data a job-notification template renders. It is library-neutral, so the runner does not depend on anything mail-internal.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender sends rendered mails over SMTP. It is safe to build once and reuse.