Overview

aSaaSin sends emails with React Email templates, styled via Tailwind, and delivered by Resend. We keep email logic in a small email service and trigger it from server actions (e.g., newsletter subscribe).

Stack & folders

  • Templates live in emails/ (e.g. NewsletterConfirmationEmail.tsx)
  • Tailwind utilities via an email-only wrapper (e.g. emails/tailwind)
  • Optional font component (e.g. emails/font)
  • Delivery with Resend from server-side code
  • Use NEXT_PUBLIC_APP_URL for absolute links and image URLs in templates

See the official React Email docs for styling guidance with React Email and Tailwind

Getting started with Resend

  1. Create an account at Resend (Dashboard → Projects).
  2. Verify a sending domain (SPF/DKIM) in Domains.
  3. Create an API key (Dashboard → API Keys).
  4. (Optional) Create an Audience for contacts.

Keep your API key secret. Use separate keys for local, staging, and production.

Service pattern

  • Email service (e.g., services/email): wraps Resend calls (add contact to Audience; send template).
  • Server actions: validate input, call the service, return success/error for UI.
  • Templates: React components with <Preview> and a single-column layout; use absolute URLs for links/images.

Preview templates locally

  • Run the React Email dev server from your project root:
npx react-email dev --dir emails
  • Open the local preview URL it prints (defaults to port 3000) to view templates live.
  • Edit templates under emails/ and refresh to see changes.

CLI reference: React Email CLI

Local development checklist

  1. Create and use a separate Resend API key for local/staging.
  2. Verify that links and images in templates use NEXT_PUBLIC_APP_URL.
  3. Test by subscribing your own email and checking deliverability.
  4. Handle errors server-side and show a friendly message in the UI.

Notes

  • Keep logic in the service; actions stay small and testable.
  • Add more templates later (password reset, plan change, invoice).
  • Styling specifics live in the Theming section (email).