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

# Inbound: Forward Emails

> How to receive inbound emails on your custom domain and forward them to your personal inbox or API webhook.

# Inbound: Forward Emails

With Mailofly Inbound Routing, you can accept incoming messages on any custom domain address (e.g. `support@yourdomain.com` or `hello@yourdomain.com`) and forward them either to a personal mailbox or an HTTP webhook.

***

## 1. Configure Inbound MX Records

Ensure your domain's DNS includes the Mailofly Inbound MX record:

* **Host**: `@` (or your subdomain, e.g. `mail`)
* **Type**: `MX`
* **Value**: `inbound.mailofly.com`
* **Priority**: `10`

***

## 2. Setting Up Forwarding via Webhook

When Mailofly receives an inbound email, it parses the MIME body, attachments, and headers into a JSON payload and dispatches it to your configured webhook endpoint.

You can set up an API route or serverless function to forward the email:

```typescript app/api/inbound-webhook/route.ts theme={null}
import { NextResponse } from "next/server";
import { Mailofly } from "mailofly";

const mailofly = new Mailofly(process.env.MAILOFLY_API_KEY!);

export async function POST(req: Request) {
  const payload = await req.json();

  // Forward incoming email to personal destination
  await mailofly.emails.send({
    from: "Forwarder <notifications@yourdomain.com>",
    to: "my-personal-inbox@gmail.com",
    subject: `Fwd: ${payload.subject}`,
    html: `
      <p><strong>Originally From:</strong> ${payload.from}</p>
      <hr />
      ${payload.html || payload.text}
    `,
  });

  return NextResponse.json({ success: true });
}
```


## Related topics

- [Forward Emails](/receiving/forward-emails.md)
- [Reply to Emails](/receiving/reply-to-emails.md)
- [Email Content](/receiving/email-content.md)
- [Retrieve Received Email](/api/receiving/retrieve-received-email.md)
- [Managing Emails](/receiving/managing-emails.md)
