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", }) }