New:New releases:CLIcreate-clubedge-app v0.49.1·Clubedge Starter v0.32.0

Clubedge Starter Docs

Email

Send email over SMTP or through Resend, behind one EmailProvider interface.

Choose with --email smtp (default), --email resend, or --email none. On a React + Vite frontend with an API, the Hono and FastAPI APIs implement every option: see A frontend and its API.

The app sends email through the EmailProvider in apps/web/src/server/email.ts. Server code imports email from @/server/email and calls it:

Any server code
import { email } from "@/server/email";

await email.send({ to, subject, text, html });

Set SMTP_URL to any SMTP server, for example smtps://user:password@smtp.example.com:465, and EMAIL_FROM to the sender, as Name <address> or an address. Most email providers (Resend, Postmark, Amazon SES, SendGrid, Mailgun) offer an SMTP endpoint.

apps/web/.env.local
SMTP_URL=smtps://user:password@smtp.example.com:465
EMAIL_FROM=My App <hello@example.com>

With Docker local services, Mailpit catches every email: SMTP on port 1025, and the inbox at http://localhost:8025.

Without a provider configured, development prints each email to the server log, so you can open links from the terminal, and production refuses to send. pnpm check:services confirms that the provider accepts the settings without sending anything.

To send email in the background with retries, see Background jobs.

A frontend and its API

With a separate API, the API sends email. Set the email variables in apps/api/.env.local.

  • Hono (Starter v0.25.0 or newer): the EmailProvider is in apps/api/src/server/email.ts, and the API's code imports email from @/server/email as above.
  • FastAPI (Starter v0.26.0 or newer): the EmailProvider is in apps/api/src/clubedge_api/email.py.
Any FastAPI code
from clubedge_api.email import email

await email.send({"to": to, "subject": subject, "text": text, "html": html})

With Better Auth, which runs in the frontend's server (apps/web/auth.server.mjs), its confirmation and password reset emails use the same provider, so set the email variables in apps/web/.env.local too. See Authentication for the emails each provider sends.

How is this guide?