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.
Build SVG ticket data from an email entry (non-PII only)
Build the data object exposed to Liquid templates
Generate SVG ticket attachments for all entries
Gets the business email from the database (uses settings cache). Returns decrypted email or empty string if not set.
Read email config from DB settings. Falls back to business email for fromAddress. Returns null if not configured.
Read host-level email config from environment variables. Returns null if not fully configured.
Type guard: checks if a string is a valid EmailProvider
Validates a basic email format: something@something.something
Normalizes email: trim and lowercase
Render all 3 parts (subject, html, text) using custom templates with fallback to defaults
Render a single Liquid template string with the given data
For testing: reset the engine (so filters can be re-registered after currency changes)
Send a single email via the configured provider. Logs errors, never throws. Returns HTTP status or undefined on non-HTTP errors.
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.
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.
Send a test email to the business email address. Returns HTTP status or undefined on non-HTTP errors.
Updates the business email in the database and invalidates the settings cache. Pass empty string to clear the business email. Email is encrypted at rest.
Validate a Liquid template by parsing it (no rendering). Returns null if valid, or an error message string if invalid.
Event data needed for email rendering (extends webhook event with display fields)
Union of all supported email provider keys, derived from the PROVIDERS map
Display labels for email providers — keys must match EmailProvider
Valid provider names, derived from the PROVIDERS map
Usage
import * as mod from "docs/email.ts";