Documentation
¶
Overview ¶
Package mailer sends transactional emails. If RESEND_API_KEY is set it uses the Resend HTTP API (recommended for cloud servers). Otherwise it falls back to Gmail SMTP — requires SMTP_USER + SMTP_PASS. If neither is configured every Send call is a no-op log (useful for local dev).
Index ¶
- func AdminAlertHTML(title, details, actionLabel, actionURL string) string
- type Config
- type Mailer
- func (m *Mailer) Enabled() bool
- func (m *Mailer) NotifyAdmin(subject, htmlBody string)
- func (m *Mailer) Send(to, subject, htmlBody string) error
- func (m *Mailer) SendInvitation(toEmail, inviterEmail, teamName, token, frontendURL string)
- func (m *Mailer) SendLoginOTP(toEmail, name, code string)
- func (m *Mailer) SendNewsletter(toEmail, name, subject, bodyHTML string)
- func (m *Mailer) SendPasswordReset(toEmail, name, token, frontendURL string)
- func (m *Mailer) SendPlanExpiryWarning(toEmail, name string, expiresAt time.Time, frontendURL string)
- func (m *Mailer) SendProvisionedWelcome(toEmail, name, orgName, tempPassword, frontendURL string)
- func (m *Mailer) SendVerification(toEmail, name, token, frontendURL string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdminAlertHTML ¶ added in v1.6.3
AdminAlertHTML builds a simple admin alert email body.
Types ¶
type Config ¶
type Config struct {
// Resend (preferred — works on DigitalOcean, no port blocks)
ResendKey string // RESEND_API_KEY e.g. "re_..."
ResendFrom string // e.g. "Mekong Tunnel <noreply@angkorsearch.dev>"
// SMTP fallback (Gmail STARTTLS port 587)
Host string // default: smtp.gmail.com
Port string // default: 587
User string // Gmail address
Pass string // Gmail App Password
From string // display name + address
// AdminEmail receives operational alert emails (new signups, requests, etc.)
AdminEmail string // ADMIN_NOTIFY_EMAIL
}
Config holds credentials for either Resend or SMTP.
type Mailer ¶
type Mailer struct {
// contains filtered or unexported fields
}
Mailer sends emails.
func (*Mailer) NotifyAdmin ¶ added in v1.6.3
NotifyAdmin sends an operational alert email to the configured AdminEmail. If AdminEmail is not set, the call is a no-op.
func (*Mailer) SendInvitation ¶ added in v1.5.8
SendInvitation sends a team invitation email with an accept link.
func (*Mailer) SendLoginOTP ¶
SendLoginOTP sends a 6-digit login verification code to the user's email.
func (*Mailer) SendNewsletter ¶
SendNewsletter sends a newsletter campaign to a single recipient. Called in a goroutine per recipient from the admin send handler.
func (*Mailer) SendPasswordReset ¶
SendPasswordReset sends the password-reset link.
func (*Mailer) SendPlanExpiryWarning ¶ added in v1.6.3
func (m *Mailer) SendPlanExpiryWarning(toEmail, name string, expiresAt time.Time, frontendURL string)
SendPlanExpiryWarning emails a student whose plan expires within the next week.
func (*Mailer) SendProvisionedWelcome ¶ added in v1.5.8
SendProvisionedWelcome sends a welcome email to a user provisioned by an org admin.
func (*Mailer) SendVerification ¶
SendVerification sends the email-verification link.