> For the complete documentation index, see [llms.txt](https://docs.mailtrap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mailtrap.io/inbound-email/receiving-emails.md).

# Receiving Emails

In this article, you'll learn how to create an inbound inbox and start receiving emails.

{% hint style="info" %}
You need account-level token to `create` an inbound inbox.&#x20;
{% endhint %}

#### Step 1. Create a folder via the API

First, you need to create a folder for categorizing and storing your inboxes. To **create a folder**, use the following command:

```
curl -X POST https://mailtrap.io/api/inbound/folders \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "Support" }'
```

**Note**: Make sure to replace `YOUR_API_KEY` with your actual [Mailtrap API token](https://docs.mailtrap.io/email-api-smtp/setup/api-tokens).

The command should give you the following output: `{"id":10,"name":"Support"}%`

#### Step 2. Create an inbox via the API

Insert your folder ID, enter the desired inbox name, and create an inbox with the following command:

```
curl -X POST https://mailtrap.io/api/inbound/folders/{folder_id}/inboxes \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "Support tickets" }'
```

The terminal should send you a following message: `{"id":15,"name":"Support tickets","address":"demo-inbox-62fedace@inbound-mailtrap.io"}%`

Your inbound inbox in this case would be: **<demo-inbox-62fedace@inbound-mailtrap.io>** and you could start sending emails to this address.

{% hint style="info" %}
If you want your email address to be under your **custom sending domain**, please see [this section](https://docs.mailtrap.io/inbound-email/receiving-emails#creating-a-custom-domain-catch-all-inbox).
{% endhint %}

#### Step 3. List messages from your inbound inbox

Mailtrap returns a fully parsed email object, including envelope fields (sender, recipients, subjects), metadata (Message-ID, references) and raw headers, all in a single JSON.

To **list messages** from your inbound inbox, use the following command:

```
curl -X GET 'https://mailtrap.io/api/inbound/inboxes/{inbox_id}/messages' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

**Note**: Make sure to replace `{inbox_id}` with your actual inbox ID (i.e., 15).

You should get the following output:&#x20;

`{"id":"1866872391602282496","inbox_id":15,"from":"Ivan Djuric` [`demo.eth@gmail.com`](mailto:demo.eth@gmail.com)`","to":["demo-inbox-62fedace@inbound-mailtrap.io"],"cc":[],"bcc":[],"reply_to":null,"subject":"Hello from the other side","message_id":"`[`2C613DD4-6E5E-429C-B430-60325BA31E25@gmail.com`](mailto:2C613DD4-6E5E-429C-B430-60325BA31E25@gmail.com)`","in_reply_to":null,"references":[],"headers":{"mime-version":"1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\))","return-path":"`[`demo.eth@gmail.com`](mailto:demo.eth@gmail.com)`"},"size":3665,"html_size":null,"text_size":24,"received_at":"2026-06-02T08:17:31.878Z","attachments":[]}`

You can use the message ID, the `id` field, to **get a message**:

```
curl -X GET https://mailtrap.io/api/inbound/inboxes/{inbox_id}/messages/{id} \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

Or, **delete a message** if you wish:

```
curl -X DELETE https://mailtrap.io/api/inbound/inboxes/{inbox_id}/messages/{id} \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### Creating a custom domain (catch-all) inbox

By default, Mailtrap-generated inboxes use an address under the `@inbound-mailtrap.io` domain. If you prefer to use your own sending domain for your inbox address, you can create a catch-all inbox under that domain.

{% stepper %}
{% step %}
**First, configure your sending domain to receive inbound emails**

1. Go to the [**Domains**](https://mailtrap.io/domains) page and select the sending domain you want to use for your inbox.
2. Open the **Domain Verification** tab.
3. Under **Add DNS records to your domain provider**, enable **Inbound domain receiving:**<br>

   <figure><img src="/files/54Ck5rIPA8MQRW7V9rWf" alt=""><figcaption></figcaption></figure>
4. Add the provided **MX record** to your domain's DNS settings.
   {% endstep %}

{% step %}
**Next, create an inbox using your own domain**

Once the MX record has been added, you will need the following:

1. Your **domain ID** (You can get this by using the [List Domains API](https://docs.mailtrap.io/developers/email-sending/domains#get-api-domains) endpoint.)
2. Your **folder ID** (You can get this by using the [List Folders API](https://docs.mailtrap.io/developers/inbound/folders#get-api-inbound-folders) endpoint.)
3. Your **API key**

Once you have all of the above, you are now ready to create an inbox:

Insert your folder ID, enter the desired inbox name, and create an inbox with the following command:

```
curl -X POST https://mailtrap.io/api/inbound/folders/{folder_id}/inboxes \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "Support tickets", "domain_id": domain_id }'
```

The terminal should send you something like this message: `{"id": 2, "name": "Support tickets", "address": "*@your-domain.com", "domain_id": 894 }`

In this case, your inbound inbox can use **any username under `@your-domain.com`** (example: `user@your-domain.com`, `support@your-domain.com`), and you can start sending emails to that address.

{% hint style="info" %}
Currently, custom domain inboxes catch all emails sent to any username under the custom domain. In the future, we plan to support custom rules and forwarding based on the username.
{% endhint %}
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mailtrap.io/inbound-email/receiving-emails.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
