Skip to content

feat(supabase): send auth email through Resend with branded templates - #45

Merged
musa-kal merged 5 commits into
mainfrom
feat/custom-smtp
Nov 17, 2026
Merged

musa-kal merged 5 commits into
mainfrom
feat/custom-smtp

Conversation

@musa-kal

Copy link
Copy Markdown
Member

Intent

Send Potluck's auth email through Resend with branded templates, because the built-in Supabase sender only delivers to the Supabase team.

  • supabase/config.toml: [remotes.production.auth.email.smtp] enabled, smtp.resend.com:465, user resend, pass = env(SUPABASE_AUTH_SMTP_PASSWORD), admin_email [email protected], sender_name Potluck; [remotes.production.auth.rate_limit] email_sent = 30; [auth.email.template.] confirmation, magic_link, recovery, email_change, reauthentication with subjects and content_path into supabase/templates; [auth.email.notification.] security notices with custom subjects and templates (the production blocks that forced default subjects are gone). Email confirmation stays on.
  • .github/workflows/deploy.yml passes SUPABASE_AUTH_SMTP_PASSWORD to config push and fails the migrate job loudly before any production change if it is empty.
  • Templates use only Supabase template variables, keep every link the app and e2e mail helper rely on, inline colours, include a text fallback link, and no em or en dashes.
  • docs/deployment.md, launch-checklist.md, security.md, architecture.md and supabase/AGENTS.md describe it.
    No secret may be committed.

What Changed

  • supabase/config.toml sends production auth email through Resend SMTP (smtp.resend.com:465, password from env(SUPABASE_AUTH_SMTP_PASSWORD), sender Potluck <[email protected]>) and caps email_sent at 30 per hour. It replaces the production blocks that forced Supabase's default notification subjects. Email confirmation stays on.
  • Adds 10 branded HTML templates in supabase/templates/, used by both the local stack and production: confirmation, magic link, recovery, email change and reauthentication, plus security notices for password, email, MFA enroll/unenroll and the new identity-linked notice. Each has its own Potluck subject, inline colours and a plain-text fallback link. Action links stay {{ .ConfirmationURL }} so the e2e mail helper still finds them. The templates folder is excluded from prettier.
  • deploy.yml passes SUPABASE_AUTH_SMTP_PASSWORD to supabase config push. If the secret is empty, the migrate job fails before it links or pushes anything to production. docs/deployment.md, launch-checklist.md, security.md, architecture.md and supabase/AGENTS.md describe the Resend setup and the templates.

Risk Assessment

✅ Low: The change is config, templates and docs that meet every intent criterion. The SMTP guard runs before supabase link, no secret is committed, the templates keep the /auth/v1/verify links the e2e helper reads plus text fallbacks, and both prior-round fixes are in place; the one leftover is a minor doc wording issue.

Testing

  • ⏭️ Test - skipped

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ supabase/config.toml:290 - New component: two extra security notices were turned on, [auth.email.notification.identity_linked] (290) and identity_unlinked (295), each with its own template. The intent asks for custom subjects and templates on the security notices and for removing the production blocks that forced default subjects. It does not ask to enable new notice types. identity_unlinked cannot fire from the app: apps/web/src never calls unlinkIdentity, or linkIdentity either. Both notices still use the project-wide 30/hour email budget and Resend's 100/day quota. Suggested fix: remove both blocks and supabase/templates/identity_linked_notification.html and identity_unlinked_notification.html, and drop the 'sign in method' wording in docs/architecture.md:933, docs/deployment.md (shared templates paragraph) and docs/launch-checklist.md. Or confirm they are intended.
  • ℹ️ supabase/templates/password_changed_notification.html:29 - The intent says templates must 'include a text fallback link'. The four action-link templates do (confirmation, magic_link, recovery, email_change). The security notices that show a 'Reset my password' button ({{ .SiteURL }}/forgot-password) give no plain-text copy of that URL. The same gap is at identity_linked_notification.html:29, identity_unlinked_notification.html:29, mfa_factor_enrolled_notification.html:29 and mfa_factor_unenrolled_notification.html:29. Please confirm whether the fallback requirement covers these buttons too. If it does, add the same 'Button not working? Paste this link' line to each.

🔧 Fix applied.
1 warning still open:

  • ⚠️ docs/architecture.md:1041 - The Hosting section still says 'auth email uses Supabase built-in SMTP for now (rate-limited); swap to Resend with a sender on fermulate.com.' This change switches production auth email to Resend, so the line is now wrong. It also contradicts the updated security-notice line at docs/architecture.md:933, along with docs/deployment.md, docs/launch-checklist.md section 3 and docs/security.md, all of which say auth email goes through Resend. The intent requires architecture.md to describe the new setup. Suggested fix: rewrite the line to say auth email goes through Resend SMTP from Potluck &lt;[email protected]&gt; ([remotes.production.auth.email.smtp], templates in supabase/templates/) and that notification email is built but off until app_config.email_notifications is turned on (launch checklist link). A grep of the changed docs, supabase/ and .github/ found no other stale 'built-in sender' text.

🔧 Fix applied.
1 info still open:

  • ℹ️ docs/launch-checklist.md:39 - The line 'Production allows 30 auth emails an hour, inside Resend's free plan (100 a day, 3,000 a month)' reads as if the cap keeps auth email inside the free plan. It does not: 30 an hour can reach 720 a day, and Resend rejects anything past 100 a day, so sign ups would then fail to send. The config.toml comment (line 521) and docs/deployment.md:71 state it accurately ('one busy hour stays under a third of the daily allowance'). Suggested fix: reword to say the hourly cap keeps a single busy hour under a third of Resend's 100 a day, and that the daily quota is not enforced by Supabase.
⏭️ **Test** - skipped

Step was skipped.

✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

musa-kal and others added 5 commits November 16, 2026 18:36
The built-in Supabase sender only reaches our own team and refuses custom
templates, so people signing up with a password never got their confirmation
link. Production now sends through smtp.resend.com as Potluck
<[email protected]>, with the key from the production environment, and at
most 30 auth emails an hour.

Sign up, sign in link, password reset, email change and the reauthentication
code get Supper Club styled templates in supabase/templates, shared with the
local stack, and every link stays the ConfirmationURL the e2e mail helper reads.
The security notices get their Potluck subjects back in production, with bodies,
and Google linking or unlinking now sends one too.

The deploy stops before db push when SUPABASE_AUTH_SMTP_PASSWORD is empty: the
CLI skips an unset env() secret, so a first push would otherwise turn on SMTP
with no password.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
Deployment lists the SUPABASE_AUTH_SMTP_PASSWORD secret, the guard that stops a
deploy without it, and what config push now sets for email. The launch
checklist marks auth email as done and keeps what is left for notification
email, which can reuse the Resend account but shares its 100 a day. Security
notes Resend as the auth email processor and how to rotate the key.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
@musa-kal
musa-kal merged commit 2de3e2c into main Nov 17, 2026
7 checks passed
@musa-kal
musa-kal deleted the feat/custom-smtp branch November 17, 2026 00:14

This branch was successfully deployed

1 active deployment
preview — bc70d235 Deployed Nov 17, 2026 by musa-kal via Deploy web to Cloudflare #124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant