Create new email addresses and mailboxes in MailSlurp using the API
How to create email addresses and mailboxes using MailSlurp's API. Custom email inboxes and disposable email accounts.
Table of contents
- Randomized addresses
- Specific addresses
- Lifespan
- Next steps
You can create MailSlurp inboxes on demand using the API, dashboard or SDK libraries.
Randomized addresses
The simplest way to create an inbox is to use a createInbox()
method. When passed no parameters MailSlurp will randomly assigned the inbox an email address ending in @mailslurp.com
. The returned object looks like this:
{
"id": "32f88182-3b6a-4f6e-8a53-59819931033a",
"userId": "6f68f0cc-4760-4e82-87ad-449c9037773b",
"created": "2019-12-06T13:04:13.998Z",
"emailAddress": "32f88182-3b6a-4f6e-8a53-59819931033a@mailslurp.com"
}
In the above example the inbox's ID is 32f88182-3b6a-4f6e-8a53-59819931033a
. The inbox's email address is 32f88182-3b6a-4f6e-8a53-59819931033a@mailslurp.com
. Any emails sent to this address will be parsed and stored under that inbox ID.
Specific addresses
You can also create inboxes using specific addresses. Simply pass the address you wish to use as an emailAddress
parameter. For example:
createInbox('user1@mycompany.com')
Note specific email addresses must use a domain that you have created.
Lifespan
For most paid plans email addresses are permanent. Some unpaid options expire after a month. For automated tests it is recommended that you create new inboxes each test run and clean up afterwards using deleteInbox
methods.
Next steps
Now lets look at how to receive emails with an inbox you have created.