Files
minstrel/internal/mailer/templates.go
T
bvandeusenandClaude Opus 5.5 bae3421057 feat(email): every email Minstrel sends uses one layout (#8150)
The password reset, the new-music and activity summaries and the SMTP
test message each drew their own page; the test message had no layout
at all. They now share internal/mailer's layout: the Minstrel name at
the top, the email's heading and message on a card in the design
system's dark theme, and a footer saying which server sent it and why,
signed "— Minstrel", with the notification-settings link on the
summaries. A plain-text body in the same frame goes alongside.

An email supplies only its content templates and a Frame (heading,
server, reason). Links, buttons and quiet text take named styles from
the layout ({{style "link"}}), so colours change in one place; an
unknown style name fails the render. The SMTP test message is a
template now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 10:27:16 -05:00

45 lines
1.5 KiB
Go

package mailer
import "embed"
//go:embed templates/password_reset.txt templates/password_reset.html templates/smtp_test.txt templates/smtp_test.html
var emailsFS embed.FS
// ResetEmailVars is the data passed to the password reset templates.
type ResetEmailVars struct {
Username string
ResetURL string
ExpiryHours int
// Server is the server's public address, named in the footer as the
// sender.
Server string
}
// ResetEmailSubject is the subject line used by the forgot-password
// flow. Exported so callers don't string-literal it independently.
const ResetEmailSubject = "Minstrel password reset"
// RenderResetEmail returns (textBody, htmlBody) for the password reset
// email.
func RenderResetEmail(vars ResetEmailVars) (string, string, error) {
return Render(emailsFS, "templates/password_reset.txt", "templates/password_reset.html", vars, Frame{
Heading: "Reset your password",
Server: vars.Server,
Reason: "a password reset was requested for your account",
})
}
// SMTPTestSubject is the subject of the message an admin sends to check
// the server's email settings.
const SMTPTestSubject = "Minstrel email test"
// RenderSMTPTestEmail returns (textBody, htmlBody) for the email settings
// test message. server is the server's public address, or "".
func RenderSMTPTestEmail(server string) (string, string, error) {
return Render(emailsFS, "templates/smtp_test.txt", "templates/smtp_test.html", struct{}{}, Frame{
Heading: "Email is working",
Server: server,
Reason: "an admin sent a test from the email settings",
})
}