product
Temporary email API for private test inboxes
Create private temporary email addresses with an explicit lifetime. Receive signup, OTP and reset emails, then manage expiry and test-data cleanup separately.
Keep a temporary inbox open for the whole test, then clean it up when the journey is finished. MailSlurp gives each address private account access, API waits and an explicit expiry, so a signup, password reset or invitation has a real place to arrive.
Use the same inbox through verification and the final application assertion. Set its lifetime before the test starts, and keep message cleanup separate from the expiry time.
Set a lifetime around the complete journey
An email can arrive before the browser is ready to use it. Allow time for application setup, provider delivery, any resend, the user's next step and the evidence you need when something fails.
For a short automated test, choose a window longer than the test's maximum runtime. For a manual review, allow the reviewer time to finish. A longer-lived staging workflow may be better served by a persistent inbox with explicit teardown.
The inbox creation API accepts either:
expiresIn: a lifetime in milliseconds from creation;expiresAt: a specific expiry timestamp. The JavaScript SDK accepts aDateobject for this option.
Choose one form and inspect the returned inbox details to confirm the configuration. Set it explicitly rather than depending on an account default.
Expiry and deletion have different jobs
The server periodically archives inboxes whose expiry time has passed. An archived inbox can no longer send or receive, while existing emails can remain. Use explicit deletion and check its result when your test needs a confirmed cleanup step; an expiry timestamp alone does not establish that the archive has already run.
Use explicit cleanup for data you want removed after a test. Keep only the permitted failure evidence before deletion, and handle the application's user record separately. Removing a MailSlurp inbox does not remove the test account in your app.
The disposable email lifecycle guide explains creation, receipt, expiry and cleanup, including how to avoid treating a configured timestamp as proof that cleanup ran.
Receive the current request's email
Create a private inbox for the test and submit its address through your application. Capture the start time before requesting the email, then use a bounded wait for the expected sender, subject or request identifier.
A resend can produce more than one message in the same inbox. Use the message for the current request, extract its link or code, and complete the verification before that application token expires. The inbox lifetime and the token lifetime are independent.
For a full example, follow the parallel password-reset test. It creates isolated inboxes with expiry configured, receives real MailSlurp messages and explicitly deletes the inboxes during teardown. The expiry is a safeguard; teardown handles explicit cleanup.
Temporary and disposable inboxes work together
You can create a new inbox for each test and give that inbox a short lifetime. Those are complementary controls:
- Disposable inboxes isolate recipients and message state between runs.
- Temporary inbox settings determine how long an address can send and receive.
- Teardown and retention rules determine what data remains after the test.
For a one-off dashboard check, the test-email-address guide follows the same address from creation to the final account result. For recurring CI checks, use the API and the framework your team already runs.
Keep failed tests diagnosable
Name or tag inboxes with the environment and test run. Record the inbox ID, message ID, relevant timestamps and failure status. Store sensitive content only where your team's test-data policy permits it; a reset token does not belong in a general build log.
If the process stops before teardown, scheduled expiry provides a fallback when the server archives the inbox. Check for leftover resources separately. Cleanup should report failures so an interrupted run does not silently become permanent test data.
Create a private temporary inbox and set its lifetime around the signup, reset or OTP journey you want to verify.