Receiving Emails
In this article, you'll learn how to create an inbound inbox and start receiving emails.
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.
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.
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:
Note: Make sure to replace {inbox_id} with your actual inbox ID (i.e., 15).
You should get the following output:
{"id":"1866872391602282496","inbox_id":15,"from":"Ivan Djuric 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","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"},"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:
Or, delete a message if you wish:
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.
First, configure your sending domain to receive inbound emails
Go to the Domains page and select the sending domain you want to use for your inbox.
Open the Domain Verification tab.
Under Add DNS records to your domain provider, enable Inbound domain receiving:

Add the provided MX record to your domain's DNS settings.
Next, create an inbox using your own domain
Once the MX record has been added, you will need the following:
Your domain ID (You can get this by using the List Domains API endpoint.)
Your folder ID (You can get this by using the List Folders API endpoint.)
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:
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.
Last updated
Was this helpful?

