# Creating inboxes

Creating real email addresses on demand is a key feature of MailSlurp. Before you start sending and receiving emails you need an inbox.

# What is an inbox?

An inbox is a private email account belonging to your API Key. Inboxes have real, unique email addresses that can send and receive emails and attachments.

Inbox features:

# Creating an inbox

You can create inboxes using the dashboard or with the API. Inboxes are either given a randomly assigned email address at creation or use the email address you provide. Note you must verify your domain to use a custom address.

Here how to create an inbox using the Javascript SDK.

const inbox = await mailslurp.createInbox();
console.log(inbox);

# Create inbox options

You can also create inboxes in other ways using the inboxController directly. An example in Javascript is as follows:

import MailSlurp from "mailslurp-client";
const mailslurp = new MailSlurp({ apiKey: "your-api-key"})
// create a controller
const inboxController = mailslurp.inboxController
// create an inbox with options
const inbox = await inboxController.createInbox({
    // use the expanded domain pool so randomly assigned email address is more varied
    useDomainPool: true,
    // permanent by default or supply an expires at time
    expiresAt: null
})
// { id: '65b5ebf7f4fa', emailAddress: '65b5ebf7f4fa@mailslurp.xyz', ... }

# Custom email addresses

By default inboxes are assigned a randomly-generated email address ending in @mailslurp.com.

For instance: 65b5ebf7f4fa@mailslurp.com. Use the MailSlurp domain pool options with inbox requests to generate email addresses with end domains selected randomly for a list of MailSlurp domains such as mailslurp.info, mailslurp.xyz etc.

You can specify custom email addresses by using a custom domain. For instance: invoices@myorg.com.

const inbox = await mailslurp.createInbox("invoices@myorg.com");
console.log(inbox.emailAddress);
// 'invoices@myorg.com'

Or using the inbox controller directly:

// create an inbox with options
const inbox = await inboxController.createInbox({
    emailAddress: 'anything@my-verified-domain.com',
})

To select your own email address you must use a custom domain. Custom domains can be purchased from any domain provider and then added to the MailSlurp dashboard.

TIP

If no email address is selected MailSlurp will by default use a randomly assigned email address ending in @mailslurp.com.

Use the useDomainPool option when creating inboxes to generate email addresses with an email address ending in mailslurp.xyz, mailslurp.info etc. This is useful when receiving emails on corporate mail servers that may filter out the default MailSlurp domain.

# Aliases and plus suffix

MailSlurp does not support + suffix email addresses such as myinbox+test@mailslurp.com. This is because this is not a part of the SMTP standard and is instead a feature that Gmail and other providers added themselves. In MailSlurp every address is treated as distinct. Use the email aliases feature to create aliases for an inbox or address. These are forwarded to your underlying email just like + addresses.

# Lifetime

All inboxes are permanent by default (provided your plan supports permanent inboxes). If you don't have a plan MailSlurp will expire inboxes after a default time for free users. For more information see expired inboxes guide.

# How inboxes work

Once you create an inbox any email sent to the inbox's email address will be received by MailSlurp, parsed, and stored. Inboxes and emails are private and permanent (unless otherwise specified). Inboxes can also send emails and route mail with webhooks.

Let's see it in action!

Next page