Email sending, templates, and notifications.

Supports multiple email providers via HTTP APIs: Resend, Postmark, SendGrid, and Mailgun.

Emails are rendered using Liquid templates with support for custom confirmation and admin notification templates.

Functions

f
buildSvgTicketData(
entry: EmailEntry,
currency: string
): SvgTicketData

Build SVG ticket data from an email entry (non-PII only)

f
getEmailConfig(): EmailConfig | null

Read email config from DB settings. Falls back to business email for fromAddress. Returns null if not configured.

f
getHostEmailConfig(): EmailConfig | null

Get host-level email config. Uses test override if set, otherwise reads env vars.

f
isEmailProvider(value: string): value is EmailProvider

Type guard: checks if a string is a valid EmailProvider

f
normalizeBusinessEmail(email: string): string

Normalizes email: trim and lowercase

f
renderEmailContent(
type: EmailTemplateType,
data: TemplateData
): Promise<EmailContent>

Render all 3 parts (subject, html, text) using custom templates with fallback to defaults

f
renderTemplate(
template: string,
data: TemplateData
): Promise<string>

Render a single Liquid template string with the given data

f
resetEngine(): void

For testing: reset the engine (so filters can be re-registered after currency changes)

f
resetHostEmailConfig(): void

For testing: reset host email config to read from env vars.

f
sendEmail(
config: EmailConfig,
msg: EmailMessage
): Promise<number | undefined>

Send a single email via the configured provider. Logs errors, never throws. Returns HTTP status or undefined on non-HTTP errors.

f
sendNtfyError(code: string): Promise<void>

Send an error notification to the configured ntfy URL Returns a promise so callers can await delivery if needed. Delivery failures are logged locally (via logErrorLocal) but never throw.

f
sendRegistrationEmails(
entries: EmailEntry[],
currency: string
): Promise<void>

Send registration confirmation + admin notification emails. Entries is an array because one registration can cover multiple events. Silently skips if email is not configured. Attaches one SVG ticket per entry to the confirmation email.

f
sendTestEmail(
config: EmailConfig,
to: string
): Promise<number | undefined>

Send a test email to the business email address. Returns HTTP status or undefined on non-HTTP errors.

f
setHostEmailConfigForTest(config: EmailConfig | null): void

For testing: set host email config directly. Bypasses env vars to avoid races.

f
updateBusinessEmail(email: string): Promise<void>

Updates the business email in the database. Pass empty string to clear the business email. Email is encrypted at rest.

f
validateTemplate(template: string): string | null

Validate a Liquid template by parsing it (no rendering). Returns null if valid, or an error message string if invalid.

Type Aliases

Variables

v
EMAIL_PROVIDER_LABELS: Record<EmailProvider, string>

Display labels for email providers — keys must match EmailProvider

v
VALID_EMAIL_PROVIDERS: ReadonlySet<EmailProvider>

Valid provider names, derived from the PROVIDERS map