for developers wiring email into their tests

An email API built for tests

Give every test run its own fresh inbox. Spin one up, read the OTP your app just sent, and move on. No shared mailboxes, no flaky polling.

Get an API keyRead the docs

Python & JS SDKs

pip install mailflat or npm i @mailflat/sdk gives you typed clients over a clean REST API.

One inbox per test

Create a fresh address per run so tests never share mailbox state.

OTP in one line

wait_for_otp() polls and returns the code, with no manual IMAP wiring.

Waiting for mail without sleeping

The slowest, flakiest line in most email tests is a fixed sleep. The API replaces it with a call that blocks until a message actually arrives and then returns it, or gives up with a clear timeout. There is a variant that returns the one-time code directly, because pulling a six-digit number out of a message body with a regular expression is a test that breaks when marketing changes the template.

Only received mail counts toward that wait, so a test that sends a message and then waits for a reply does not match its own outgoing copy.

Built for CI, not just a laptop

Every inbox is created and destroyed through the API, so parallel jobs do not share state or fight over a fixture mailbox. Runs clean up after themselves: empty the messages and keep the address, or delete the address entirely.

There is a scaffolding command that generates a working project (Playwright, Vitest or pytest) already wired to a real inbox, so the first green test does not require reading a reference first.

No per-plan rate limit on sending

Competing test-mail services sell throughput: send more per hour by paying more, or hit a daily ceiling. We do not meter it that way. Outgoing mail is queued and retried rather than rejected, so a burst of messages is accepted and worked through instead of being turned away.

The honest caveat: there is a limit on very large concurrent uploads, because a few dozen simultaneous multi-megabyte attachments is a memory problem no pricing tier can wish away. Ordinary sending, with or without small attachments, is not metered.

Read the details

Testing and CIPatterns for parallel runs, cleanup and flake-free waiting.One-time codesGetting the verification code out of a message reliably.Every language and frameworkPlaywright, Cypress, pytest, Jest, Selenium and more.AttachmentsReading files out of received mail and sending them back.
from mailflat import MailFlat
 
mf = MailFlat(api_key)
inbox = mf.create(label="signup-test")
app.register(email=inbox.address)
otp = inbox.wait_for_otp(timeout=30)
assert app.verify(otp)

Frequently asked questions

Which languages are supported?

Official Python (pip install mailflat) and JavaScript/TypeScript (npm i @mailflat/sdk) SDKs, plus a plain REST API.

Can each test get its own inbox?

Yes. Create a fresh address per test run; messages auto-purge so nothing leaks between runs.

How do I read the verification code?

Call wait_for_otp(); it polls the inbox and returns the code once it arrives.

Related

temporary email apiemail for ai agentsdisposable email

Ready to try it?

Get an API key

MailFlat for instant email inboxes for testing, automation & AI agents.