MailSlurp logo

as

Temp Mail API: Temporary Email API for Developers and QA Teams

Use a temporary email API to create disposable inboxes, receive messages, and automate email testing in CI/CD.

Looking for a temporary email API or temp mail API? MailSlurp provides disposable inbox creation, email waiting utilities, and full REST/SDK support for test automation.

Create a free account to obtain an API access key, then call endpoints in HTTP, GraphQL, or official SDKs.

Executive summary

  • Create temporary inboxes programmatically for each test run.
  • Send and receive real messages, including attachments.
  • Use wait methods to assert delivery reliably in CI.
  • Scale from quick temp mail checks to full workflow automation.

inbox-tool

Create temporary email accounts

If you need accounts for testing applications or email processes MailSlurp's free temp mail api can be used to create real email addresses on demand. Each inbox has an email address that can send and receive emails. You can control inboxes using the API or one of the official clients in your programming language. Let us see an example.

Setup NodeJS client

Install with npm if you use JavaScript or find another client on the developer page.

npm install --save mailslurp-client

Next import the client into code or tests and set your API key.

// import mailslurp-client
const MailSlurp = require("mailslurp-client").default;
// OR import { MailSlurp } from "mailslurp-client"

// create a client
const apiKey = process.env.API_KEY ?? "your-api-key";
const mailslurp = new MailSlurp({ apiKey });

Create an inbox

Use the createInbox method in the temp mail api to create an inbox:

const inbox = await mailslurp.createInbox();
// { id: '123', emailAddress: '123@mailslurp.com' }

Sending emails

Send emails from your temp mailbox using the sendEmail method:

await mailslurp.sendEmail(inbox.id, {
  to: [inbox.emailAddress],
  subject: "test",
});

Read emails using API

You can read emails that your inboxes receive using the waitFor commands:

// wait for first email
const latestEmail = await mailslurp.waitForLatestEmail(inbox.id, timeoutMs);
expect(latestEmail.subject).toContain("test");

Temp mail API checklist for CI and production workflows

To move from quick disposable-email checks to stable release automation, use this sequence.

Get started today

MailSlurp is free for personal use and offers simple pricing for companies. Please see code examples and developer docs for more information.