Temp mail
in Node.js.
Create a disposable inbox, poll it, and pull the verification code — straight from your test suite.
const res = await fetch("https://evilmail.pro/api/temp-email", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.EVILMAIL_KEY,
},
body: JSON.stringify({ ttlMinutes: 30 }),
});
const { data } = await res.json();
console.log(data.email); // [email protected]Temp mail in Node.js is the clean way to test email flows without a real inbox or a shared Gmail account. With the EvilMail API you create a throwaway address, trigger your signup or password-reset flow, poll the inbox over HTTP, and read the one-time code out of the message — end to end, in seconds, with nothing to clean up. Every call is a plain `fetch` with an `X-API-Key` header, so it drops into Jest, Playwright, or any CI runner with zero dependencies.
Why use temp mail in Node.js
End-to-end signup tests
Spin up a fresh inbox per test, run the real registration flow, and assert on the verification email — no mocks, no stale accounts.
CI/CD without a real mailbox
Every call is a stateless HTTP request with an API key, so it runs headless in GitHub Actions, GitLab CI or Jenkins with no browser and no shared inbox.
OTP & magic-link extraction
Read the message body and pull the six-digit code or the confirmation link with a one-line regex, then continue the flow programmatically.
Parallel-safe isolation
Each address is independent, so hundreds of tests can run in parallel without colliding on the same mailbox.
The flow — Node.js temp mail in 3 calls
Create a disposable inbox
const create = await fetch("https://evilmail.pro/api/temp-email", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.EVILMAIL_KEY,
},
body: JSON.stringify({ ttlMinutes: 30 }),
});
const { data } = await create.json();
const { email, sessionToken } = data;
// hand `email` to your signup flow, keep `sessionToken` to read the inboxPoll until the email arrives
async function waitForMail(token, tries = 20) {
for (let i = 0; i < tries; i++) {
const r = await fetch(`https://evilmail.pro/api/temp-email/${token}`);
const { data } = await r.json();
if (data.messages?.length) return data.messages;
await new Promise((s) => setTimeout(s, 3000)); // wait 3s, retry
}
throw new Error("No mail arrived in time");
}
const messages = await waitForMail(sessionToken);Read the message & extract the code
const { uid } = messages[0];
const r = await fetch(
`https://evilmail.pro/api/message/${uid}?token=${sessionToken}`,
{ headers: { "X-API-Key": process.env.EVILMAIL_KEY } },
);
const { data: mail } = await r.json();
const otp = (mail.text || "").match(/\b(\d{6})\b/)?.[1];
console.log("Verification code:", otp);Node.js temp mail — FAQ
Q1How do I get a temp mail address in Node.js?−
Send a POST to https://evilmail.pro/api/temp-email with your X-API-Key header. The response contains a real, working address and a sessionToken you use to read the inbox. No SDK needed — it is a plain fetch.
Q2Can I use this for automated testing (Jest, Playwright, Cypress)?+
Yes — that is the main use case. Create an inbox in a beforeAll/setup step, run your flow, poll the inbox, extract the code, and assert. Because each call is a stateless HTTP request, it works in any runner and in CI.
Q3How do I extract a one-time code from the email?+
Read the full message via GET /api/message/{uid}?token=…, then run a regex over mail.text or mail.html. A pattern like /\b(\d{6})\b/ pulls a six-digit OTP; adjust it for magic links or longer codes.
Q4Do I need an API key, and is there a rate limit?+
You need an API key from your EvilMail dashboard. Free and paid tiers have different rate limits; paid plans also unlock custom domains and permanent mailboxes for longer-lived test accounts.
Q5How long does the inbox live?+
Set ttlMinutes when you create it (up to 24 hours on the free flow). For test accounts you want to keep, use a custom domain on a paid plan so the address never expires.
Temp mail in other languages
One API key. Disposable inboxes at scale.
Create unlimited throwaway addresses, poll them over HTTP, and pull verification codes straight into your tests and CI. Free to start; custom domains and higher limits on paid plans.

