Resend package in Inbox Zero codebase.
In this article, we review Resend package in Inbox Zero codebase. We will look at:
-
packages/resend folder.
-
How the emails are sent.

packages/resend folder
Inbox Zero uses this resend package to send transactional emails to users.
Resend
Resend provides email API for developers. Below code demonstrates a simple example in Node.js.
import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); (async function () { const { data, error } = await resend.emails.send({ from: 'Acme <onboarding@resend.dev>', to: ['delivered@resend.dev'], subject: 'Hello World', html: '<strong>It works!</strong>', }); if (error) { return console.error({ error }); } console.log({ data }); })();
In the emails folder, you will find the emails that will be rendered.

packages/resend/src/index.ts is defined as shown below:
/** biome-ignore-all lint/performance/noBarrelFile: fix later */ export * from "./send"; export * from "./contacts";
Contacts
contacts is defined as shown below:
import { resend } from "./client"; export async function createContact(options: { email: string; audienceId?: string; }) { if (!resend) { console.warn("Resend not configured"); return; } const audienceId = process.env.RESEND_AUDIENCE_ID || options.audienceId; if (!audienceId) throw new Error("Missing audienceId"); return resend.contacts.create({ email: options.email, audienceId }); } export async function deleteContact(options: { email: string; audienceId?: string; }) { if (!resend) { console.warn("Resend not configured"); return; } const audienceId = process.env.RESEND_AUDIENCE_ID || options.audienceId; if (!audienceId) throw new Error("Missing audienceId"); return resend.contacts.remove({ email: options.email, audienceId }); }
Uses resend API to create or delete a contact in your Resend account.
Send
send.tsx has sending email related functions.

How the emails are sent
I pulled two references of sendEmail API defined in the resend package as described in the above sections.
web/utils/ai/actions.ts
You will find the following code in ai/actions.ts file.
const send_email: ActionFunction<{ subject?: string | null; content?: string | null; to?: string | null; cc?: string | null; bcc?: string | null; }> = async ({ client, args }) => { if (!args.to || !args.subject || !args.content) return; const emailArgs = { to: args.to, cc: args.cc ?? undefined, bcc: args.bcc ?? undefined, subject: args.subject, messageText: args.content, }; await client.sendEmail(emailArgs); };
web/../api/resend/summary/route.ts
You will find the following code in summary/route.ts
import { sendSummaryEmail } from "@inboxzero/resend"; ... export const GET = withEmailAccount("resend/summary", async (request) => { // send to self const emailAccountId = request.auth.emailAccountId; request.logger.info("Sending summary email to user GET", { emailAccountId }); const result = await sendEmail({ emailAccountId, force: true, logger: request.logger, }); return NextResponse.json(result); }); ... async function sendEmail({ emailAccountId, userEmail, }: { emailAccountId: string; userEmail: string; }) { const token = await createUnsubscribeToken({ emailAccountId }); return sendSummaryEmail({ from: env.RESEND_FROM_EMAIL, to: userEmail, emailProps: { baseUrl: env.NEXT_PUBLIC_BASE_URL, coldEmailers, needsReplyCount: typeCounts[ThreadTrackerType.NEEDS_REPLY], awaitingReplyCount: typeCounts[ThreadTrackerType.AWAITING], needsActionCount: typeCounts[ThreadTrackerType.NEEDS_ACTION], needsReply: recentNeedsReply, awaitingReply: recentAwaitingReply, unsubscribeToken: token, }, }); }
This is a clean way to deal with transactional emails in your monorepo since you will have all Resend related API in one package that can be imported across the apps workspaces.
About me:
Hey, my name is Ramu Narasinga. I study codebase architecture in large open-source projects.
Email: ramu.narasinga@gmail.com
I spent 200+ hours analyzing Supabase, shadcn/ui, LobeChat. Found the patterns that separate AI slop from production code. Stop refactoring AI slop. Start with proven patterns. Check out production-grade projects at thinkthroo.com