> ## Documentation Index
> Fetch the complete documentation index at: https://react.email/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Send (& receive) emails using Inbound

> Learn how to send and receive emails using React Email and the Inbound Node.js SDK.

## 1. Install dependencies

Get the [react-email](https://www.npmjs.com/package/react-email) package and the [Inbound Node.js SDK](https://www.npmjs.com/package/inboundemail).

Make sure you have an account on [inbound](https://inbound.new?utm_source=react-email%20docs\&utm_medium=email\&utm_campaign=react_email_campaign), you will need an inbound API key.

<CodeGroup>
  ```sh npm theme={"theme":{"light":"github-light","dark":"vesper"}}
  npm install inboundemail react-email
  ```

  ```sh yarn theme={"theme":{"light":"github-light","dark":"vesper"}}
  yarn add inboundemail react-email
  ```

  ```sh pnpm theme={"theme":{"light":"github-light","dark":"vesper"}}
  pnpm add inboundemail react-email
  ```

  ```sh bun theme={"theme":{"light":"github-light","dark":"vesper"}}
  bun add inboundemail react-email
  ```
</CodeGroup>

## 2. Create an email using React

Start by building your email template in a `.jsx` or `.tsx` file.

```tsx email.tsx theme={"theme":{"light":"github-light","dark":"vesper"}}
import * as React from 'react';
import { Html, Button } from "react-email";

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

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

export default Email;
```

## 3. Send email

<Info>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.</Info>

Import the email template you just built and use the Inbound SDK to send it.

```tsx theme={"theme":{"light":"github-light","dark":"vesper"}}
import { Inbound } from 'inboundemail';
import { Email } from './email';

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

await inbound.emails.send({
  from: 'you@example.com',
  to: 'user@gmail.com',
  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.

```tsx theme={"theme":{"light":"github-light","dark":"vesper"}}
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 <react.email@inbound.new>",
  react: <Email url="https://example.com" />
});

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


```

## Try it yourself

<Card title="Get started on Inbound" icon="arrow-up-right-from-square" iconType="duotone" href="https://inbound.new?utm_source=react-email%20docs&utm_medium=email&utm_campaign=react_email_campaign">
  See it on our examples.
</Card>
