Email
Apps/Web apps/Email

Email

A web app sends its email through your own Resend account. Until you connect one, Inference Bureau sends production's sign-in emails and team invitations for it, up to 100 a day. Each email is a React Email file in web/emails/, previewed beside its code in Files; in development without Resend, each goes to Logs instead, with its links clickable.

Templates in web/emails/

The starter's emails are confirm-email.tsx, reset-password.tsx and sign-in-link.tsx, each taking { link, email }. Each file exports subject (a string, or a function of the email's props when it names them) and, as its default, the component, which takes the email's props: link, its main action's URL, and whatever else it shows. PreviewProps on the component is the sample the preview renders.

layout.tsx holds what they share, in Inference Bureau's email look (light, with a dark version for mail apps that ask): brand (the app's name; logo, a square PNG or JPEG's https:// address, Inference Bureau's mark until the app has its own; button and buttonText, the button's colours), the frame (EmailLayout: preview line, eyebrow, heading, and reason, the footer's reason for sending) and its parts (Paragraph, Strong, ActionButton, LinkFallback, Note). Change wording or look there, not in the code that sends them, which only picks the template. A new email is a new file in the same shape; components come from the react-email package (Text, Heading, Button, Img, Section…), with inline styles, since mail apps ignore stylesheets.

// web/emails/welcome.tsx: a new email, in the shape of the starter's.
import { ActionButton, EmailLayout, LinkFallback, Paragraph } from "./layout";

export const subject = "Welcome to ib-portal";

export default function Welcome({ link, email }: { link: string; email: string }) {
  return (
    <EmailLayout preview="Your account is ready" eyebrow="Welcome" heading="You're in" reason={`Sent to ${email} because an account was created with it.`}>
      <Paragraph>Your account is ready. Open it to finish setting up.</Paragraph>
      <ActionButton href={link}>Open your account</ActionButton>
      <LinkFallback href={link} />
    </EmailLayout>
  );
}

Welcome.PreviewProps = { link: "https://example.com/account", email: "ada@example.com" };

Sending one

sendEmail in web/lib/email.ts renders the template's HTML and plain text with @react-email/render and sends it. Actions send emails too: a build puts a copy of web/emails/ beside api/, so an action imports a template by the path it has in the app's folder. Import only web/emails/ from api/, never the rest of web/.

// From a page, a route handler or a server action (web/):
import { sendEmail } from "../lib/email";
import * as Welcome from "../emails/welcome";

const result = await sendEmail({ to: String(user.email), template: Welcome, props: { link, email: String(user.email) } });
// result: { sent, reason: "not-set-up" | "refused" | null, preview, logged? }

// From an action (api/lib/…): the same template, by its path in the app's folder.
import * as Welcome from "../../web/emails/welcome";
Means
emailReady()RESEND_API_KEY and EMAIL_FROM are both set, or production has Inference Bureau's sender: emails go out.
emailToLogs()A development environment without them: emails go to Logs.
{ sent: false, reason: "not-set-up" }Neither: nothing was sent, and the console says so. The pages that offer an email check the two above first, so a visitor isn't offered one that can't go.
{ sent: false, reason: "refused" }Resend refused it (an unverified domain, a bad address), or Inference Bureau's sender did (a limit, a pause); the console has the answer.

Links in the starter's emails start with IB_APP_URL, the environment's own address (production's primary domain once it has one), so they work from development and production alike. Tests load templates with esbuild: { jsx: "automatic" } in vitest.config.ts.

Development: to Logs

Without RESEND_API_KEY and EMAIL_FROM, development sends each email to the environment's Logs instead of an inbox: an email event named after the subject, with the recipient, the plain text and the links, which the event's page makes clickable. The page that sent it shows the link too, so sign-up, password reset and the sign-in link can be followed end to end from the dashboard. Nothing is delivered. The app posts the email to Inference Bureau with its environment token (POST /v1/apps/<app>/environments/<env>/email, which takes to, subject, text and up to ten http(s) links). In production the same address is Inference Bureau's sender, below.

With Resend connected, development sends for real, through the same account. Use a sender you can receive at, or connect Resend on production only (set production's own values and leave development's empty) and keep development's emails in Logs.

Production: our sender or Resend

Production never writes emails to Logs. Without Resend, Inference Bureau sends its sign-in emails for it, so sign-up works on the first deploy: email confirmation, password reset, sign-in links and team invitations, each a template marked with export const kind (confirm, reset, sign-in, invite). They go out in Inference Bureau's own wording with your app's name, from "<app> via Inference Bureau" <signin@signin.inferencebureau.com>, not as your files in web/emails/ render them, and each is an email event in production's Logs. Any other email (an order confirmation, a reminder) isn't sent without Resend: sendEmail logs why to the console.

For your own domain, your own wording, more than our limits or any other email, connect Resend on Settings → Integrations: it checks the key with Resend, warns when the sender's domain isn't in that account or isn't verified yet, and sets two variables (production uses development's values unless it has its own; see Environment variables):

VariableValue
RESEND_API_KEYA key from resend.com (API Keys), marked secret.
EMAIL_FROMThe sender, on a domain verified in Resend: ib-portal <hello@ib-portal.com>.

With Resend connected, the app's code calls Resend's API with the key and Inference Bureau's sender steps aside. settings.ib.ts names the integration (integrations: ["resend"]). Problems warns while production has neither Resend nor our sender, which is an app whose web/lib/email.ts is older than the sender: ask the assistant to update it from the starter, or connect Resend. When Google or GitHub sign-in is connected, the warning says what still works without email and what doesn't.

Our sender's limits

Limit
Per app100 emails a day (UTC), all kinds together.
Per recipient5 emails an hour from one app to one address.
Linkshttps:// on production's own address or one of its active domains; anything else is refused.
PauseTwo spam complaints, or five permanent bounces that are also a tenth of the week's sends, pause the app's sending for 7 days. Bounces, complaints and the pause are email events in Logs, and Problems says until when.

Past a limit, or while paused, sendEmail answers { sent: false, reason: "refused" } and the starter's pages say the email couldn't be sent. Connecting Resend lifts all of them. Production picks up the sender at its next deploy.

The preview in Files

Open an email in web/emails/ in Files and the email it sends shows beside the code at phone width, rendered by development's dev server from the saved file with the sample in its PreviewProps, so it's what gets sent. Save and it renders again once the dev server has the file. Light | Dark forces the email's dark styles on or off, as mail apps with dark mode show it; HTML | Text shows the plain-text part; layout.tsx previews with any of the emails. Send test (admins and members with Edit) sends it to you or a teammate with [Test] in the subject, through the environment's Resend, or to Logs without it; it goes to people on your team only.

The dev server renders it at /_ib/emails, a route every build adds when the app has web/emails/ and @react-email/render in its package.json. Production answers 404 there: its emails are only ever sent.

An older app with no web/emails/ has no preview. Add the folder and the two packages from a new app's package.json (@react-email/render and react-email) and it gets one.

An older Site's emails

A Site, which a web app could start as until November 15, 2026, has no templates. Its web/lib/email.ts sends plain messages, sendEmail({ to, subject, lines, link?, replyTo? }), through the same Resend variables, and to Logs in development without them, the same way. web/lib/forms.ts sends three: a new lead to LEADS_TO (a variable; the lead's address as reply-to), an acknowledgement to the visitor, and the newsletter's confirmation link. A lead is saved whether or not its emails go out. To send an issue to the list, read subscriber records with confirmed true and put unsubscribeLink(subscriber) in every email; never email an unconfirmed address more than its confirmation.