Inbox creation guide

How to create email addresses using MailSlurp. Compare the options available when generating mailboxes.

MailSlurp email accounts are called inboxes. You can use the API, dashboard, or SDK client libraries.

Basic example: use random address

You can create email accounts with randomized addresses using MailSlurp domains.

// create a randomly assigned email address
const mailslurp = new MailSlurp({ apiKey });
const { id, emailAddress } = await mailslurp.createInbox();

Use custom domain

Register a domain to use custom email addresses:

const { emailAddress } = await mailslurp.createInbox({
  emailAddress: "test5@mydomain.com",
});

Use short addresses

To generate email addresses under 31 characters use the useShortAddress option:

const inbox = await mailslurp.inboxController.createInboxWithOptions({
  createInboxDto: {
    useShortAddress: true,
  },
});
expect(inbox.emailAddress.length).toBeLessThan(31);

Virtual inboxes

Virtual mailboxes will never send to external recipients and can be used as a mail trap:

const inbox = await mailslurp.inboxController.createInboxWithOptions({
  createInboxDto: {
    useShortAddress: true,
  },
});
expect(inbox.emailAddress.length).toBeLessThan(31);

Temporary mailboxes

For throwaway temp email accounts use the expiresIn options:

const inbox = await mailslurp.inboxController.createInboxWithOptions({
  createInboxDto: {
    useShortAddress: true,
  },
});
expect(inbox.emailAddress.length).toBeLessThan(31);

More options

See the creating inboxes guide for more examples.