Zurück zum Blog

How Developers Use Temporary Email for Testing (With API Examples)

Every developer has done it. You're testing a sign-up flow and you type test123@gmail.com into the email field. Then test456@gmail.com. Then you run out of ideas and start using asdfjkl@gmail.com.

This is bad for three reasons: the emails bounce (messing up your deliverability metrics), you can't verify the actual email content, and if you're testing in production, you might be spamming real people.

Temporary email APIs solve this properly.

The Problem With Manual Testing

When testing email-dependent flows manually, developers typically:

  1. Use their personal email (gets spammed, mixes test data with real mail)
  2. Use fake addresses that don't exist (can't verify email content)
  3. Use Mailinator or similar (shared inboxes, anyone can read your test emails)
  4. Hardcode test@example.com (breaks any flow that actually sends mail)

None of these approaches let you test the full flow: sign up, receive confirmation email, click verification link, verify account is activated.

Using tempy.email API for Automated Testing

tempy.email has a REST API that lets you create disposable mailboxes programmatically and poll for incoming emails.

Basic Flow

# 1. Create a mailbox (returns a unique address)
curl -X POST https://tempy.email/api/v1/mailbox \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/json"

# Response: { "address": "sleek.steel.amet@17mur6.tempy.email", "expiresAt": "..." }

# 2. Use that address in your sign-up flow
# (your test automation fills the form with this address)

# 3. Poll for the confirmation email
curl https://tempy.email/api/v1/mailbox/sleek.steel.amet@17mur6.tempy.email/emails \
  -H "X-Api-Key: your-api-key"

# Response: array of emails with subject, body, HTML content

Playwright E2E Test Example

import { test, expect } from '@playwright/test';

test('user can sign up and verify email', async ({ page, request }) => {
  // Create a temp mailbox
  const mailbox = await request.post('https://tempy.email/api/v1/mailbox', {
    headers: { 'X-Api-Key': process.env.TEMPY_API_KEY }
  });
  const { address } = await mailbox.json();

  // Fill sign-up form
  await page.goto('https://yourapp.com/signup');
  await page.fill('[name="email"]', address);
  await page.fill('[name="password"]', 'TestPass123!');
  await page.click('button[type="submit"]');

  // Wait for verification email
  let emails = [];
  for (let i = 0; i < 30; i++) {
    const res = await request.get(
      `https://tempy.email/api/v1/mailbox/${address}/emails`,
      { headers: { 'X-Api-Key': process.env.TEMPY_API_KEY } }
    );
    emails = await res.json();
    if (emails.length > 0) break;
    await page.waitForTimeout(1000);
  }

  expect(emails.length).toBeGreaterThan(0);
  expect(emails[0].subject).toContain('Verify');

  // Extract verification link from email body
  const verifyUrl = emails[0].bodyText.match(/https?:\/\/\S+verify\S+/)?.[0];
  expect(verifyUrl).toBeTruthy();

  // Click verification link
  await page.goto(verifyUrl);
  await expect(page.locator('.success-message')).toBeVisible();
});

Webhook Alternative (No Polling)

Instead of polling, you can set a webhook URL when creating the mailbox. tempy.email will POST to your endpoint whenever an email arrives:

curl -X POST https://tempy.email/api/v1/mailbox \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"webhookUrl": "https://your-test-server.com/email-hook"}'

This is faster and eliminates the polling loop entirely.

CI Pipeline Integration

Add temporary email testing to your CI pipeline:

# GitHub Actions example
- name: Run E2E tests with email verification
  env:
    TEMPY_API_KEY: ${{ secrets.TEMPY_API_KEY }}
  run: npx playwright test --project=e2e

Every test run gets fresh, unique email addresses. No shared state, no cleanup needed. Addresses auto-expire after 10 minutes (extendable via API if your tests need longer).

Common Use Cases

  • Sign-up flow testing — Full end-to-end verification
  • Password reset testing — Verify reset emails arrive and links work
  • Notification testing — Confirm transactional emails render correctly
  • Newsletter testing — Verify subscription/unsubscription flows
  • Multi-user testing — Create dozens of mailboxes for load testing

Getting Started

  1. Sign up for a free API key at tempy.email/developers
  2. Start with 10 free credits (1 credit = 1 mailbox)
  3. Each mailbox receives unlimited emails during its lifetime

No credit card required. The free tier is enough for testing your integration before committing to a plan.

Veröffentlicht Mai 11, 2026