Core Concepts

MailSlurp is a simple REST API for creating randomized email inboxes which can send and receive emails programmatically.

Why would you want to do that? The idea is to test email functionality in your application by sending and receiving real emails from a randomly generated address that is unique to each test.

Usually, as developers, we skip this aspect of end-to-end testing or simply test manually. MailSlurp provides a simple, free way to thoroughly test email interactions within your application.

Let's demonstrate a simple use case. (For more in-depth code examples, see the examples section.) MailSlurp has an official Javascript Client to use in your tests but here the core concepts are illustrated with curl for simplicity.

1. Create a unique email address during a test
$ curl -X POST https://api.mailslurp.com/inboxes?apiKey=test
2. Parse the response and obtain the address
{"payload":{"id":"example-id","address":"e20b6cfb-dfdb-4eeb-8b2e-5b2b35fa3aa4@emaile2e.com"},"message":""}
3. Trigger an action in your test that sends an email to the given address
$ ./sign-up-a-user.test.sh
4. Fetch the latest email for the address
$ curl https://api.mailslurp.com/inboxes/example-id?apiKey=test
5. Parse the response
{"payload":[{"body":"Your verification code is 1337"}],"message":""}
6. Use the email body to verify your apps behavior

For instance use the verification code sent to a signed up user's email address to verify the user. For a more in-depth example on this topic see the examples section.