Home/Integrations/React Email
Modern Email UI Components•Component-Based Email Framework

How to Send React Email Templates with Mailofly

Design responsive, bulletproof transactional email templates using React, Tailwind CSS, and TypeScript. Render to HTML on the fly and deliver via Mailofly REST API.

npm install @mailofly/node @react-email/components @react-email/render
Setup Tutorial

Get Up and Running in 3 Easy Steps

01

Install dependencies

Install `@mailofly/node` along with `@react-email/components` and `@react-email/render` in your project.

02

Create your React Email component

Author responsive JSX templates using React Email primitives like `<Container>`, `<Text>`, and Tailwind CSS styling.

03

Render and send with Mailofly

Call `render(<Template />)` server-side to generate HTML, then pass it directly into `mailofly.emails.send({ html })`.

Production-Ready Code Example

Copy and paste into your project. Fully typed and tested.

app/api/send-react-email/route.ts
import { Mailofly } from "@mailofly/node";
import { render } from "@react-email/render";
import { WelcomeEmail } from "@/emails/welcome";
import { NextResponse } from "next/server";

const mailofly = new Mailofly({
  apiKey: process.env.MAILOFLY_API_KEY!,
});

export async function POST(request: Request) {
  try {
    const { email, name } = await request.json();

    // 1. Render React Email component to static HTML
    const emailHtml = await render(
      WelcomeEmail({ name, loginUrl: "https://yourdomain.com/login" })
    );

    // 2. Dispatch via Mailofly REST API
    const data = await mailofly.emails.send({
      from: "Acme App <notifications@yourdomain.com>",
      to: [email],
      subject: `Welcome to Acme, ${name}!`,
      html: emailHtml,
      tags: [{ name: "template", value: "welcome-react" }],
    });

    return NextResponse.json({ success: true, messageId: data.id });
  } catch (error: any) {
    return NextResponse.json({ error: error.message }, { status: 500 });
  }
}
Why Developers Love It

Engineered for React Email

Declarative JSX Email Architecture

Say goodbye to complex nested tables. Build maintainable, modular components with standard React patterns.

Zero Serverless Socket Timeouts

Because Mailofly uses HTTP REST API, rendering and sending in Vercel or AWS Lambda completes in milliseconds without SMTP connection drops.

Type-Safe Template Props

Catch missing variables and typo bugs at build time with full TypeScript type safety across your email components.

Got Questions?

Frequently Asked Questions about React Email

Yes! In your Server Action file, mark 'use server', render your React component using render() from @react-email/render, and pass the resulting HTML string directly to mailofly.emails.send({ html }).

Start Sending from React Email in Minutes

3,000 free emails every month. Copy your API key, run the code snippet, and watch your delivery logs in real time.