Listoca

Emails

How Listoca's emails leave the server, and how to set up Resend, the provider that sends them in production.

Every email is a React Email template in packages/mail/src/templates, translated through the mail i18n scope. In production Resend sends them. Locally they land in Mailpit at http://localhost:3044 and nothing leaves your machine.

How an email is sent

EmailSent by
auth emailssend-email, right away, when Supabase Auth calls the send-email hook
every other emailsend-queued-email, within a minute, from a row in email_outbox

In production Auth sends only the email change confirmation; locally it also sends the sign-in code and link. Everything else (invitations, notifications, the daily summary, billing, the contact form, the newsletter confirmation) is queued with private.enqueue_email(...).

send-queued-email retries a failed send up to five times with a growing delay and keeps the error in the row's last_error (Scheduled work). Both functions go through createMailer (packages/mail/src/send-email.tsx), which hands the rendered email to the provider named by MAIL_PROVIDER.

Adding or changing a template: the add-or-edit-an-email skill. bun run dev:mail previews every template at http://localhost:3023.

Providers

WhereMAIL_PROVIDERSet in
productionresenddeploy/supabase/functions.env.example, or Coolify step 6
localmailpitsupabase/config.toml ([edge_runtime.secrets])
unit testsconsolepackages/functions/src/testing.ts

packages/mail also has smtp and postmark providers. Listoca doesn't use them; switching is MAIL_PROVIDER and that provider's key (packages/functions/src/env.ts).

Setting up Resend

  1. Add the domain. In Resend's dashboard, Domains → Add Domain, with the domain of the address you send from (hello@example.com sends from example.com). Pick the region there; the privacy policy names it.

  2. DNS records. Add the DKIM and SPF records Resend shows at your DNS host, and wait until the domain shows as verified. Add a DMARC record yourself (a TXT on _dmarc); start with v=DMARC1; p=none; and tighten it once the reports look clean.

  3. API key. API Keys → Create API Key. With NEWSLETTER_PROVIDER=resend the same key also adds newsletter contacts, which takes Full access. Without the newsletter, Sending access limited to the domain is enough.

  4. The functions' settings, in /opt/supabase/functions.env (from deploy/supabase/functions.env.example) or in Coolify's variables:

    MAIL_PROVIDER=resend
    MAIL_FROM=Listoca <hello@example.com>
    RESEND_API_KEY=CHANGE_ME

    MAIL_FROM must be on the verified domain, or Resend refuses every email. The functions read the file when their container starts: docker compose up -d in /opt/supabase after a change, or redeploy in Coolify.

  5. Send one. Submit the marketing site's contact form: it queues an email to CONTACT_EMAIL. Within a minute it shows in Resend's Emails log. If it doesn't, look at the row in email_outbox: last_error holds Resend's answer.

The privacy policy names the email provider ([EMAIL PROVIDER] and [EMAIL PROVIDER COUNTRY] in apps/marketing/content/legal/privacy.*.mdx): put in Resend and the region from step 1.

Newsletter

NEWSLETTER_PROVIDER=resend adds a confirmed sign-up as a Resend contact, with the same RESEND_API_KEY. RESEND_NEWSLETTER_SEGMENT_ID puts new contacts in a segment, the one you send broadcasts to. The double opt-in and the forms: Marketing site.

On this page