Skip to main content

1. Install dependencies

Get the @react-email/components package and the Inbound Node.js SDK. Make sure you have an account on inbound, you will need an inbound API key.
npm install inboundemail @react-email/components

2. Create an email using React

Start by building your email template in a .jsx or .tsx file.
email.tsx
import * as React from 'react';
import { Html, Button } from "@react-email/components";

export function Email(props) {
  const { url } = props;

  return (
    <Html lang="en">
      <Button href={url}>Click me</Button>
    </Html>
  );
}

export default Email;

3. Send email

When integrating with other services, you need to convert your React template into HTML before sending. Inbound takes care of that for you. You can just directly pass the React template to the SDK.
Import the email template you just built and use the Inbound SDK to send it.
import { Inbound } from 'inboundemail';
import { Email } from './email';

const inbound = new Inbound(process.env.INBOUND_API_KEY);

await inbound.emails.send({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'hello world',
  react: <Email url="https://example.com" />,
});

4. Reply to an email

Use the Inbound SDK to reply to an email with the same template you just created.
import { Inbound } from 'inboundemail';
import { Email } from './email';

const inbound = new Inbound({
    apiKey: process.env.INBOUND_API_KEY
});

// sending an email via inbound
await inbound.emails.send(email.id,{
  from: "React Email <[email protected]>",
  react: <Email url="https://example.com" />
});

// replying to an email that was received via inbound
await inbound.emails.reply(email.id,{
  from: "React Email <[email protected]>",
  react: <Email url="https://example.com" />
});


Try it yourself

Get started on Inbound

See it on our examples.